cancel
Showing results for 
Search instead for 
Did you mean: 

How to print any variable value in the external serial monitor through FTDI using STM32F0308-DISCO board. I have tried the UART example to do that only message can be print but not the values of any variable. How to do that please share your thoughts.

Pratyush
Associate II
7 REPLIES 7
gbm
Lead III

That's quite common and basic thing. Search for "STM32 printf redirection". See the syscalls.c file generated by CubeIDE.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

"only message can be print but not the values of any variable"

What do you mean by that?

If you can print "messages", then you must have the basic output working, surely?

In what form? Human/ASCII?

char string[16];

int i = 12345;

HAL_UART_Transmit(hUART, (uint8_t *)string, sprintf(string, "%d", i), 1000);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

thanks for your reply, i am new to stm so i followed some debugging tutorial and i have tried but no luck, this is the link which i have followed.

"https://www.youtube.com/watch?v=-X8tndfqTu8&list=PL7tUZeMaichqrlJN4PGu3-n6DbYrvoG-s&index=4"

so i need a debugging console which should print the value which i mentioned.

please help me to resolve this .

Hello,

Thanks for the reply,

I want to print the variable data in the IDE debugger i mean SWV CONSOLE so i have tried the way which is mentioned in the tutorial link

"https://www.youtube.com/watch?v=-X8tndfqTu8&list=PL7tUZeMaichqrlJN4PGu3-n6DbYrvoG-s&index=4"

now i am using STM32446RET6 custom board and for this i have used ST-LINK as a STM32F0308-DISCO by removing CN2 connectors.

still i didn't get any data in the console please help to resolve this.

thank you.

@Pratyush​ "still i didn't get any data in the console"

Nothing at all?

But you said you were getting "messages" (you still haven't explained what you meant by that) - are you saying that even that has now stopped?

You also didn't answer the question from @Community member​  - are you trying to send in human-readable (ASCII) text form, or as binary?

Moving in all directions here..

SWO/SWV connectivity would be critically dependent on core clocking speed, and the relationship between that and the SWCLK to get the baud rate correct. Solder bridges on the DISCO board might need to be removed to cleanly disconnect SWO/PB3 from the on-board target MCU as CN2 only manages the SWDIO/SWCLK connections.

At the most basic level ITM_SendChar() should be able to transport characters.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..