Keil – floating point support
Hi,
I have problem with floating point formatting of sprintf function. Integer formatting works fine. Is there something rtos specific, I should setup?
Thanks for any clue.
Konrad
Keil – floating point support
Are you saying it only doesn’t work when you are using the RTOS? So in a small non RTOS APP the floating point formatting does work?
Keil – floating point support
It looks like…
The following line of code works with non-rtos version of application.
sprintf(CommonBuffer,"I =%5.2fA Delta =%4.1f%%n", (float)current/100, (float)CalcDeviation(current)/10);
In rtos version of appplication formatting itself look ok, but values of formatted variables are not right (usually zeros).
Keil 3.40, FreeRTOS 5.1.2, LPC2388
Regards,
Konrad
Keil – floating point support
May be it is because the sprintf() function is reenterable. I just guess.
Regards
Keil – floating point support
I had a similar problem with floating point on the FreeRTOS Luminary Stellaris demo.
The problem is the float is passed in as a 64 bit double and the ARM requires it to be aligned to 64 bits. The demo set the stack up 32 bit aligned. The changes I made to 4.7.2? using GCC were
FreeRTOS/Demo/CORTEX_LM3Sxxxx_Eclipse/RTOSDemo/startup.c
added the attribute to stack declaration to force 64 bit alignment
static unsigned long __attribute__ ((aligned (8))) pulStack[STACK_SIZE];
FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h
changed to
#define portBYTE_ALIGNMENT 8
(I also had to add floating point printing to the supplied printf)
Keil – floating point support
Hi,
This is the point. The problem is with passing 64 bit variable as function parameter in Task.
When, during debugging, I changed appropriately SP the sprintf function started working correctly.
I tried to setup my Keil project similarly, but unfortunately without success.
I appreciate any hints.
Konrad
Keil – floating point support
Hi,
I managed it running under heap_2 memory model.
The modifications should be exactly like "dig" suggested.
For Keil it is:
#define portBYTE_ALIGNMENT 8
in portmacro.h
__align(8) static struct xRTOS_HEAP
{
unsigned portLONG ulDummy;
unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
} xHeap;
in heap_2.c
I am still confused in heap_3 memory model for which the problem still exists.
I checked. Configuration of heap in Startup.s file is 8 bytes aligned.
So why it does not work in this case?
konrad