2015-09-01 10:13 AM
Hi to every one,
It's the first time that I use the STM32CubeMX + SWSTM32 to program a stm32f401RE board. I have done already some example project but I can't use the printf() function to communicate with a terminal ( Tera Term) on the PC. Somebody can explain me how I can do it?Thank you in advance!!2015-09-01 10:36 AM
Hi,
I'd highly recommend you to take a look to the project under STM32Cube F4 package:STM32Cube_FW_F4_V1.8.0\Projects\STM32F401RENucleo\Examples\UART\UART_Printf\SW4STM32It shows how to retarget the C library printf function to the UART in order to output the printf message on the Hyperterminal using USART2 interface connected to ST-LINK MCU.-Syrine-2015-09-02 03:10 AM
Thank you, I followed your suggestion and now I'm able to use the printf() function.
But I can't print the float numbers; For example:/************************/float value=3.5; printf(''%f'', value);/************************/in the terminal it doesn't write anything;How can I resolve that?Thank you again...2015-09-02 06:12 AM
Open your SW4STM32, go to: project -> properties > C/C+ build > Settings > MCU GCC Linker > Miscellaneous > Linker flags: add this flag: -specs=nano.specs -u _printf_float
-Syrine-2015-09-02 07:59 AM
I added the flag and now when I want to print a float variable the function prints 0.0000000.
For example:/**********************************/float value=4.5;printf(''MyFloat= %f'', value);/**********************************/I get ''MyFloat= 0.0000000''. Why?Thank you so much for your time...2015-09-03 03:32 AM
Try to add this flag: -specs=nosys.specs
(-specs=nosys.specs -specs=nano.specs -u _printf_float )
to previous options or add the syscalls.c file to your project -Syrine-2015-09-03 07:21 AM
Done!! But again I get 0.000000 when I use float variables... :(
2015-09-03 08:09 AM
Hi,
I think that changing _estack in your linker(*.ld) file can resolve the issue._estack should be 8byte aligned, so modify_estack = 0x20017FFF; /* end of RAM */by_estack = 0x20018000; /* end of RAM */Regards2015-09-04 02:18 AM
Yesss.. Now it works!!! Thank you so much BochT!! And Thank you to Syrine for his patience...
Regards2015-09-04 07:26 PM
Another forum have mentioned the issue already.