2024-07-25 03:55 AM
Currently using a STM32L4R9I-DISCO and I've been struggling to get the SWV ITNM Data Console to work so I can do some debugging. I'm quite new to this, but I've followed every tutorial online to enable UART and how to set it all up, to no avail. I've managed to get the Trace Log to work, but I am looking for values of the variables in loops as the code is executed. Is there any other way to do this or is someone capable of helping me set this up?
Solved! Go to Solution.
2024-07-25 04:48 AM - edited 2024-07-25 04:50 AM
@Hafez1 wrote:help me set printf up so I can print the values of variables to the console?
ST Knowledgebase article on redirecting printf to a UART:
And a 3rd-party article on the same:
EDIT:
So sending printf to SWV is just a matter of putting "send-a-char-to-swv" instead of "send-a-char-to-uart" ...
2024-07-25 04:04 AM - edited 2024-07-25 04:05 AM
Let's begin with the ITM. Just call ITM_SendChar and ensure it goes out to the CubeIDE window. Send LF (\n) after some text characters to flush the line. If this won't work, something is wrong at ITM level (wrong clock value, something grabs the SWO pin, something not enabled in the GUI...).
Every ST evaluation board comes with a hidden gift to the buyer: a free debugging puzzle and IQ test )) Enjoy!
2024-07-25 04:14 AM
@Hafez1 wrote:I'm quite new to this
New to which - just STM32? embedded in general? C programming in general?
@Hafez1 wrote:struggling to get the SWV ITNM Data Console to work ... I've followed every tutorial online to enable UART and how to set it all up
You realise that SWV and UART are different things?
2024-07-25 04:23 AM
New to Embdedded in general. Sorry my wording's a bit off I'm both tired and new to embedded. I meant that I've tried setting up SWV, and UART through PuttyGen for debugging and both don't seem to give me what I want. Thanks for the input.
2024-07-25 04:30 AM
2024-07-25 04:33 AM
Yes, I am.
Thank you, I'll do as such. Worried about tackling printf later; everyone seems to complain about how it's hell to get it to work.
2024-07-25 04:41 AM - edited 2024-07-25 04:43 AM
@Hafez1 wrote:Worried about tackling printf later; everyone seems to complain about how it's hell to get it to work.
It really isn't.
But it does rely entirely on having the basic send-a-character working - so do that first!
EDIT:
ST Knowledgebase article on redirecting printf to a UART:
And a 3rd-party article on the same:
2024-07-25 04:43 AM
I've got it to work and I can see it in my SWV ITM. Could you please help me set printf up so I can print the values of variables to the console?
2024-07-25 04:48 AM - edited 2024-07-25 04:50 AM
@Hafez1 wrote:help me set printf up so I can print the values of variables to the console?
ST Knowledgebase article on redirecting printf to a UART:
And a 3rd-party article on the same:
EDIT:
So sending printf to SWV is just a matter of putting "send-a-char-to-swv" instead of "send-a-char-to-uart" ...
2024-07-25 05:00 AM
+1 and for printf, don't forget the stdout is line-buffered. So end every line with \n.
Or use stderr: fprintf(stderr...) - it should print immediately.