2019-09-03 10:46 PM
Hi all.
i have problem using float and double in mytest application.
I hjave an aplication generated using stm32cubeide Version: 1.0.2
Build: 3566_20190716-0927 (UTC), CUBEMX ver 4.21.0.
Application use FreeRTOS Kernel V10.0.1 and task.
in a task i read temperature valu from a sensor and try to set the value in a variable.
Variable contain garbage but with debug i can see rigth value returned from sensor.
i cannot get hint from google search.
Someone ha the same problem? may you suggest same?
Regards,
Carmelo GAllucci
2019-09-03 10:47 PM
i can add also that prinf of float give me hard fault.
2019-09-04 12:38 AM
For printf, try this include: https://github.com/mpaland/printf
I cannot help you more without additional information
2019-09-04 05:28 AM
thanks i will try to avoid hardfault with printf.
Some other info:
i have this code:
float currtempvalue = MPC9808_getTemperature();
float currtempres= MPC9808_getResolution();
printf("MPC9808: temperature %f - resolution %f \r\n",currtempvalue ,currtempres);
whit debug i can see that MPC9808_getTemperature() return, correctly 28.5 but currtempvalue is assigned with garbage.
I try also to modify ftos aligment (from 8 to 4) as MCU. nothing changed.
Regards,
carmelo
2019-09-04 11:25 AM
The reason for your hard-fault in printf is explained here:
http://www.nadler.com/embedded/newlibAndFreeRTOS.html
@Markus GIRDLAND (ST Employee) - Yet another example of your customers getting tripped up by STM's incorrect newlib integration...
2019-09-06 09:42 AM
@stm32f4 - Carmelo, did this fix your problem??
http://www.nadler.com/embedded/newlibAndFreeRTOS.html
Please let us know!
2019-09-08 03:47 AM
hello Dave. Sorr for delay.
Yes i do.Thanks so much for you hint. I did exacle what you suggest with link.
I fix also the garbage behavior. It was my mistake. i did not include the correct .h in mai main. Compiler not complain at all only a warning. afte that all work correctly.
Thank a lot.
Carmelo
2019-09-08 08:55 AM
do you already use this ?
The float formatting support is not enabled, check your MCU Settings from "Project Properties > C/C++ Build > Settings > Tool Settings", or add manually "-u _printf_float" in linker flags.
2019-09-08 10:28 AM
@mal h - If you read Carmelo's reply above, he has everything working now.
So yes, he is using the correct linker flags, in addition to the heap_useNewlib I provided...
2019-09-08 08:42 PM
@Dave Nadler
Thanks for your solution. It helps.