nrf: etm-trace for nrf52840dk and nrf5340dk

nrf52840dk: 16 MHz TRACECLK (hardware cap) width 4, P25 soldered, SW7=Alt;
no family code needed (J-Link arms TRACECONFIG). nrf5340dk: TRACE_ETM
builds force the TAD port to 16 MHz (SystemInit's 64 MHz is marginal),
+3 ns sample timing; the interface MCU's UART1 flow control drives the
trace pins - SB27/SB28 must be cut (P0.10/P0.11 = TRACEDATA1/0).
This commit is contained in:
hathach
2026-07-24 15:28:51 +07:00
parent ca1b7821fa
commit 927f12415e
3 changed files with 12 additions and 2 deletions

View File

@ -21,7 +21,7 @@ void OnProjectLoad (void) {
Project.SetTracePortWidth (4);
// User settings
File.Open ("../../../../../../examples/device/cdc_msc/cmake-build-pca10056/cdc_msc.elf");
File.Open ("../../../../../../examples/cmake-build-nrf52840dk/device/cdc_msc/cdc_msc.elf");
}
/*********************************************************************

View File

@ -29,9 +29,13 @@ void OnProjectLoad (void) {
Project.SetTraceSource ("Trace Pins");
Project.SetTracePortWidth (4);
// +3 ns sample point: the DK's analog-switch/SWO stubs make TD=0 marginal
// (Ozone sends TraceSampleAdjust TD=0 when no timing is set); solid across
// the +2..+4 ns band with SB27/SB28 cut, SB57 (SWO) left intact
Project.SetTraceTiming (3000, 3000, 3000, 3000);
// User settings
File.Open ("../../../../../../examples/device/cdc_msc/cmake-build-pca10095/cdc_msc.elf");
File.Open ("../../../../../../examples/cmake-build-nrf5340dk/device/cdc_msc/cdc_msc.elf");
}
/*********************************************************************

View File

@ -165,6 +165,12 @@ static nrfx_gpiote_t _gpiote = NRFX_GPIOTE_INSTANCE(0);
//
//--------------------------------------------------------------------+
void board_init(void) {
#if defined(TRACE_ETM) && defined(NRF5340_XXAA)
// SystemInit (ENABLE_TRACE) sets the TAD trace port to 64 MHz, which is
// marginal through the DK's switch stubs - 16 MHz streams reliably (matches the validated nrf52840dk) and is
// ample bandwidth for the 64 MHz core
NRF_TAD_S->TRACEPORTSPEED = TAD_TRACEPORTSPEED_TRACEPORTSPEED_16MHz;
#endif
#if !defined(NRF54H20_XXAA) && !defined(NRF54LM20A_ENGA_XXAA)
// stop LF clock just in case we jump from application without reset
NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;