Quality RTOS & Embedded Software

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


Keil - floating point support

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

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


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.


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

added the attribute to stack declaration to force 64 bit alignment
static unsigned long __attribute__ ((aligned (8))) pulStack[STACK_SIZE];

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
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.

RE: Keil - floating point support

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


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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists