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
}