2016-03-08 12:27 AM
I am using STM32L476RG/F401RE nucleo board and trying to view the output of printf of float value on the terminal I/O.I am using IAR.
But what I am getting is this : value = %ffor the below code : float value = 168/21617.0printf(''value = %f '' ,value) ;I am already using the semihosting option ticked.Is there any specific setting/condition?It doesn't happens with STM32F29I Disco.Br.Rp #!stm32 #rtfm2016-03-08 03:18 AM
Hi Rp,
Be sure that you use the right settings: Project>Options>General Options>Print formatter: try to selectLarge without multibytes
option The code:float
value=168/2160;
printf(
''%f
''
,value) ;
The Output of the terminal I/O:
0.007772
-Syrine-
2016-03-08 04:41 AM
>Be sure that you use the right settings: ...
To be more precise, in ''project options''->''General Options''->''Library options'', ''Printf formatter'', you need to specify ''Large'' of ''Full''. Otherwise, you get no floating point support for the printf() function family.
2016-03-08 09:26 AM
2016-03-08 09:45 AM
Also, make sure that your stack pointer is initialized to an address which is a multiple of 8, otherwise a floating point value will not be passed to printf correctly.
2016-03-08 10:34 AM
Also, make sure that your stack pointer is initialized to an address which is a multiple of 8, otherwise a floating point value will not be passed to printf correctly.
Yeah, I'm pretty sure that's not a hard rule for most Cortex-Mx parts, where 4-byte alignment is workable for LDRD. The Cortex-M0 is the most problematic, where everything needs alignment. The current F7 also doesn't support doubles in hardware.A lot of GNU/GCC platforms have this kind of idiocy in the linker scripts, which is like a goddamn cancer spread all over the place._estack = 0x2002FFFF; /* end of RAM */
http://www.openstm32.org/Using+CCM+Memory?structure=Documentation
The top of memory would be 0x20030000, the stack pre-decrements.