Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Keil - floating point support

Posted by Konrad Heksel on March 16, 2009
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

RE: Keil - floating point support

Posted by MEdwards on March 16, 2009
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?

RE: Keil - floating point support

Posted by Konrad Heksel on March 17, 2009
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

RE: Keil - floating point support

Posted by Forest YU on March 17, 2009
May be it is because the sprintf() function is reenterable. I just guess.

Regards

RE: Keil - floating point support

Posted by David Gesswein on March 18, 2009
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)

RE: Keil - floating point support

Posted by Konrad Heksel on March 18, 2009
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

RE: Keil - floating point support

Posted by Konrad Heksel on March 18, 2009
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


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS