2024-04-30 02:47 AM
Hi,
I am having stm32F103C6T6 Development Board. When i enable -u_printf_float flag for Float printing on 16x2 LCD it takes upto 15KB of total space .
Please guide. what else can be done ?
-u_printf_float Enabled :
Without Flag for Float
2024-04-30 03:04 AM
The stm32F103C6T6 has no hardware floating point, so it all has to be done in software - which uses up flash space.
@asking wrote:what else can be done ?
Don't use floating point!
2024-04-30 05:11 AM
Try to set compiler optimization for code space.
2024-04-30 06:29 AM
Not sure how much that will help, as the software floating point and the printf stuff are in binary libraries...
:thinking_face:
2024-04-30 06:56 AM - edited 2024-04-30 07:06 AM
>>Please guide. What else can be done ?
You could learn or read about things more deeply, so you can think through the situation, rather than be guided at every step?
Perhaps use your own, lighter weight, application specific variants?
Could you convert and break down the float values into integer sub-components that you could print with the classic integer formatting methods. ie "%d.%03u"
Things like dtoa() are quite heavy, probably a large portion of the cost here.
As Andrew said, the ideal situation might be to not use floating-point. Can your number ranges be accommodated by a fixed point solution using integers?
You could use a more capable part? One where the 15KB library burden is less onerous to the total available space, and to the application. Some of the newer parts have physically smaller die, but larger memories. Yield per wafer tending to be the driver of cost. Is the 15 year old device the best choice here? You might need to think more deeply here so you can expand your comfort-zone.
2024-04-30 07:15 AM
The math can be done without printing, and the printing portion probably isn't going to get markedly smaller on a library using an FPU, faster perhaps. The defaults for printf() is typically the double, so you'd be into the bigger CM7 FPU-D implementations for them to assist with the math.
If floating point can be removed that would save the most space. Say an appropriately chosen fixed point or scaled integer?