What do you need to do to get printf to format floating point numbers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-07 03:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-07 03:23 PM
Using STM32CubeIDEwith an STM32L433RBTx micro. I've gone through all the settings and nothing helps.
It formats a string into garbage.
sprintf( strBuff, "%4.2f", (double)12.34 );
strBuff[0] = 0
strBuff[1] = 0
strBuff[2] = 0x2e (Which is correct)
strBuff[3] = 1
strBuff[4] = 0x20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-07 03:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-07 04:39 PM
Unfortunately, I tried changing the linker script as outlined in the link you sent and everything else I can think of, and still get the same garbage.
I'm trying to figure out how to change the library that it links with in STM32CubeIDE and haven't figured that out yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-08 01:06 AM
You need to consult the STM32CubeIDE tutorials/documentation. Usually, this is found in the project properties.
This IDE seems relatively new, and bug prone. Consider setting up the project again, with the proper library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-08 09:32 AM
It turns out that the fix was to rewrite the _sbrk routine to what was outlined in the first reply. I hadn't looked at it carefully enough initially.
The original _sbrk routine assumes that you have a linear address space and the heap is below the stack always. That is not the case when you use freeRTOS and have multiple stacks that are statically created. I had to add a label to the heap end in the linker script file and follow what was done in the first reply example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-08 09:37 AM
The sorry state of the _sbrk has been lamented before... ST still also has code generating unaligned stacks via linker scripts..
Up vote any posts that you find helpful, it shows what's working..