2023-10-18 09:35 AM - edited 2023-10-18 11:22 AM
This problem is common, but I've reviewed my setup and everything appears to be correct, yet it still doesn't work.
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!
2023-10-18 09:41 AM
Some screenshots may help make my configuration clear:
2023-10-18 11:47 AM - edited 2023-10-18 11:49 AM
i just can say: it works. but getting it to work - is more like a game with greetings from mr. murphy .
try:
- not limit the clock, just leave on auto. (it should set the best speed itself.)
- uncheck the timestamps enable (it will overflow the buffer after some seconds..)
- click the red button ...2, 3 times and again when pause/debug , re-start debug again...after some tries it should work.
+ when it works, it will also work on next debug sessions, no need to start again. :)
2023-10-18 11:55 AM
Thanks for your response.
I tried not limiting the SWO speed, also limiting it at 200KHz, 2000KHz, and other values. I tried 1920KHz to match 25MHz / 13.
I tried with and without timestamps.
I have clicked that red button many times, starting and stopping debugging with it on and off.
None of this voodoo is working. :(
I have an STDC14 Tag-Connect so to try another programmer it'd need to be V3SET or V3MINI. Do those work reliably?
2023-10-18 12:00 PM
Usually its a relationship between what the core is running at, and the clock used by the ST-LINK.
I'd perhaps try the old ST-LINK Utilities, or the SWV mode in STM32 Cube Programmer.
Sorry more of a Keil guy myself..
2023-10-18 12:17 PM
I gave STM32CubeProgrammer's SWV mode a try. It doesn't show anything for 25MHz SYSCLK. With verbose level 3 I see logs like:
15:13:49:419 : r ap 0 @0x1FFF76DE 0x00000004 bytes Data 0xFFFF00D0
15:13:50:421 : r ap 0 @0x1FFF76DE 0x00000004 bytes Data 0xFFFF00D0
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:363 : Unknown Packet
15:13:51:424 : r ap 0 @0x1FFF76DE 0x00000004 bytes Data 0xFFFF00D0
I could change my HSE oscillator. Is 25MHz a poor choice? Is there a standard value around 25MHz that would work better?
2023-10-18 12:39 PM - edited 2023-10-18 12:52 PM
i never used a core at 25M. so cannot say about it better or not...
on F411 not tried yet. on F303 at 60M core.
just : its working on H743 and H563 , core at 200 or 250M. with st-link V2 ("clone") and V3 .
->
2023-10-18 06:49 PM
Are you saying you tried a V3 at 25MHz SYSCLK and it worked? If so, thanks for giving that a try. I don't see the V3 anywhere, instead I see: V3SET, V3MINIE, V3MODS, and V3PWR. Which one did you try?
Should I expect ST to eventually chime in to this thread? If not, is there a way to escalate an issue to get support?
2023-10-18 11:23 PM - edited 2023-10-18 11:26 PM
Never ever at 25M core.
Why don't you go higher, with using the pll ?
+
I have V3mods, soldered to proto board and standard 2.54mm pin header.
Ask STM direct -> ols.st.com
Try...
2023-10-19 07:58 AM
Turns out my HSE is actually 10MHz. It's unbelievable I suffered so long without realizing it! My code was running with SystemCoreClock showing 25000000 so I assumed it was good. SWO is working now after specifying 10MHz. I feel so dumb but I'm happy to be able to move on. Sometimes even the simplest problem can cause much pain!