0

Here is my setup:

[target(S32k146)] <-(SWD)-> [iSystem IC5000 with a CoreSight adapter] <-> [Host (Windows 10, WinIDEA 9.17]

I am trying to establish a debug channel via SWO. I have an oscilloscope attached to the SWO wire between the target and the IC5000.

  • when I run my firmware from a debug session, I can see the trace output on the SWO pin with my scope. The WinIDEA, however, does not show me the trace output, which is why I want to try to capture the trace data with a J-Link device.
  • when the target runs standalone (i.e. without supervision through the debug interface from the WinIDEA), there is no trace output on the SWO pin.

Am I missing some sort of GPIO configuration that is implicitly done by my IDE at the start of a debug session? What should I do in order to get the trace output in the standalone run?

Here is my initialization (based on the link above):

void SWO_Init(uint32_t stimuliMask, uint32_t SWOBaudRate, uint32_t cpuCoreFreqHz) {
  CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk; /* enable trace in core debug */
  TPI->SPPR = 0x00000002;
  TPI->ACPR = (cpuCoreFreqHz / SWOBaudRate) - 1;
  ITM->LAR = 0xC5ACCE55; /* ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC */
  ITM->TCR = ITM_TCR_TraceBusID_Msk | ITM_TCR_SWOENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_ITMENA_Msk; /* ITM Trace Control Register */
  ITM->TPR = ITM_TPR_PRIVMASK_Msk; /* ITM Trace Privilege Register */
  ITM->TER = stimuliMask; /* ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port. */
  DWT->CTRL = 0x400003FE;
  TPI->FFCR = 0x00000100;
}

I have tried to add the initialization for the IO pin, but with no effect:

void  FUN_CCper_InitSWOPins(void) {
  PORTA->PCR[10] |= PORT_PCR_MUX(7); // set IO pin to SWO channel
}
skobls
  • 67
  • 5

1 Answers1

3

Your ITM trace configuration is correct, but you are facing some trouble with the configuration of the debug port.

On ARM Cortex devices the SWO trace pin can only be used in combination with SWD (Serial Wire Debug), because the same pin is also used for the TDO signal used in JTAG mode. On S32K1xx controllers the debug port always comes out of reset in JTAG mode and can only be switched to SWD mode by a specific sequence which is sent by an external device. For this reason, when the S32K1xx controller is reset in standalone operation the SWO pin is actually used for the JTAG TDO signal, hence the expected trace output does not appear on this pin.

When configured correctly, both the iC5000 as well as the J-Link device will automatically send the JTAG to SWD switch sequence when attaching to the S32K1xx controller. After the switch to SWD has occurred, the trace messages will appear on the SWO pin and can be observed by an oscilloscope.

More detailed information about this topic can be found in the S32K1xx Reference manual (section 58.3) and the ARM Cortex documentation.

Full disclosure, I'm an iSYSTEM employee. Thank you for posting your question, it resulted in a knowledge base article to ensure that any of our users encountering this issue in the future have a solution.

PG_root
  • 46
  • 2