Hi,
Please let me know if you were able to solve this issue.
I am facing a similar issue.
If "Force SWO initialization by IDE" checkbox is checked in MCUXpresso IDE,
the SWO signal is output from PB3 of the MIMXRT1170-EVK board.
But if I perform the same operations displayed on the Trace Console using my code, nothing is output on the SWO signal from PB3 of the MIMXRT1170-EVK board.
This is the output from the console:
--------------------------------------------------------------------------------------------------------------------------------------
**---------- Considered CoreSight Components ----------**
DWT 0xE0001000
ITM 0xE0000000
Trace Funnel 0xE0045000
SWO 0xE0048000
Trace Funnel 0xE0043000
ETM 0xE0041000
**---------- Enable use of trace and debug blocks (DWT, ITM, ETM, TPIU) ----------**
*0xE000EDFC = 0x01000000 // DEMCR [Enable trace and debug block]
**---------- Configure SWO ----------**
*0xE0048FB0 = 0xC5ACCE55 // LOCKACCESS [Unlock registers]
*0xE0045FB0 = 0xC5ACCE55 // LOCKACCESS [Unlock registers]
*0xE0045000 = 0x000003FF // CSTF [Program Funnel]
*0xE0043000 = 0x000003FF // CSTF [Program Funnel]
*0xE00480F0 = 0x00000002 // SWO_SPPR [Select NRZ protocol]
*0xE0048010 = 0x00000006 // SWO_CODR [Set prescaler]
*0xE0000E80 = 0x0001000C // ITM_TCR [Disable ITM]
*0xE0000E80 = 0x0001040A // ITM_TCR [Enable DWT->TPIU. Configure timestamp]
*0xE0000E80 = 0x0001040B // ITM_TCR [Enable ITM block]
*0xE0000E00 = 0x00000001 // ITM_TER [Enable stimulus ports]
**---------- Enable ITM_TRACE ----------**
*0xE0000E80 = 0x0001040A // ITM_TCR [Disable ITM]
*0xE0000E80 = 0x0001040B // ITM_TCR [Enable ITM block]
*0xE0000E00 = 0x00000001 // ITM_TER [Enable stimulus ports]
*0xE0000E40 = 0x00000008 // ITM_TPR [Set privileges]
--------------------------------------------------------------------------------------------------------------------------------------
This is my code in which I am performing the same operations:
void SWO_Init(uint32_t cpuCoreFreqHz, uint32_t SWOSpeed)
{
// SWOSpeed in Hz, note that cpuCoreFreqHz is expected to be match the CPU core clock
volatile uint32_t SWOPrescaler = (cpuCoreFreqHz / SWOSpeed) - 1;
// Enable use of trace and debug blocks (DWT, ITM, ETM, TPIU)
*(volatile unsigned int*)0xE000EDFC = 0x01000000; // [DEMCR.TRCENA][Enable trace and debug blocks]
*(volatile unsigned int*)0xE0045FB0 = 0xC5ACCE55; // UNLOCK
*(volatile unsigned int*)0xE0048FB0 = 0xC5ACCE55; // UNLOCK
*(volatile unsigned int*)0xE0045000 = 0x000003FF; // [FUNNEL][CSTF]
*(volatile unsigned int*)0xE0045000 = 0x00000303; // [FUNNEL]
*(volatile unsigned int*)0xE0043000 = 0x000003FF; // [FUNNEL][CSTF]
*(volatile unsigned int*)0xE0043000 = 0x000003FF; // [FUNNEL]
*(volatile unsigned int*)0xE00480F0 = 0x00000002; // [SWO][SPPR] //TPIU_SPPR Select NRZ mode
*(volatile unsigned int*)0xE0048010 = SWOPrescaler;// // [SWO][CODR] //TPIU_ACPR here is 64K Example: 72/48 = 1,5 MHz 0x0000000A;
*(volatile unsigned int*)0xE0000E80 = 0x0001000C; // [ITM][ITM_TCR][Disable ITM]
*(volatile unsigned int*)0xE0000E80 = 0x0001040A; // [ITM][ITM_TCR][Enable DWT->TPIU. Configure timestamp]
*(volatile unsigned int*)0xE0000E80 = 0x0001040B; // [ITM][ITM_TCR][Enable ITM block]
*(volatile unsigned int*)0xE0000E00 = 0x00000001; // [ITM][ITM_TER][Enable stimulus ports]
*(volatile unsigned int*)0xE0000E80 = 0x0001040A; // [ITM][ITM_TCR][Disable ITM]
*(volatile unsigned int*)0xE0000E80 = 0x0001040B; // [ITM][ITM_TCR][Enable ITM block]
*(volatile unsigned int*)0xE0000E00 = 0x00000001; // [ITM][ITM_TER][Enable stimulus ports]
*(volatile unsigned int*)0xE0000E40 = 0x00000008; // [ITM][ITM_TPR][Set privileges]
}
I would appreciate any help in this matter.
Thank you.