SWV ITM Data Console is empty
This problem is common, but I've reviewed my setup and everything appears to be correct, yet it still doesn't work.
- My programmer is an STLINK-V3PWR, connected via a 6 pin Tag-Connect (TVCC, SWDIO, NRST, SWCLK, GND, SWO) to an STM32F411CEU6.
- In the STM32CubeIDE IOC, under SYS I've enabled Trace Asynchronous Sw.
- In my STM32CubeIDE debug config, I'm using GDB, SWD, and enabled SWV at 25MHz, matching my SystemCoreClock. SWO clock is limited to 2000KHz (25MHz / 13 = 1920KHz).
- In the SWV ITM Data Console settings, I've checked port 0. The red "Start trace" button is pressed.
- My logging uses ITM_SendChar and ends with \n. I can suspend execution and step through the ITM_SendChar function in core_cm4.h: ITM and port 0 are enabled and ITM->PORT[0U].u8 = (uint8_t)ch; is executed.
- Still, nothing appears in the SWV ITM Data Console or SWV Trace Log views.
At this point it seems like SWO is not connected, but it is definitely connected to pin PB3.
Next I tried this code:
while (1) {
ITM_SendChar('h');
ITM_SendChar('i');
ITM_SendChar('\n');
int i = 100000;
while (i > 0) i--;
}
If I place this in main() after everything (in USER CODE BEGIN 2 where SystemCoreClock is 25000000) I still get nothing. However, if I place it before SystemClock_Config() (in USER CODE BEGIN Init just after HAL_Init() where SystemCoreClock is 16000000) then I see entries in the SWV Trace Log view: ITM port 16 and DATA_TRACE_VALUE (comp 0) (W). I have no comparator configured. Maybe these are erroneous due to clocks not matching, but does it at least shows that SWO is indeed connected?
Edits:
I changed the SWV core clock to 16MHz and now I see entries in SWV ITM Data Console! But only when logging before SystemClock_Config(). Why doesn't it work after SYSCLK is changed to 25Mhz and I specify 25MHz for the SWV core clock? I also tried 96MHz, but got the same nothing.
SWV core clock 16Mhz with SYSCLK 25MHz and logging after SystemClock_Config(), I see gibberish SWV Trace Log entries. That makes sense. Changing the SWV core clock to 25MHz, I see nothing. That makes no sense! Maybe the STLINK-V3PWR doesn't work correctly? It's pretty new. I updated the firmware to the latest (V4.J3.B1.P4).
Changing SYSCLK to 16MHz (by using HSI), I do get logging. That's great, but I can't use HSI. I'm doing time sensitive operations (modulating a laser to keep it eye safe) and need to use HSE.
I don't know what else to try. I need logging and don't have a UART available because I was planning to use SWO. Any assistance is greatly appreciated!
