# sprintf not working with floating point after Scheduler started.

**URL:** <https://forums.freertos.org/t/sprintf-not-working-with-floating-point-after-scheduler-started/466>\
**Category:** Kernel\
**Created:** [October 22, 2013, 11:11pm UTC](https://forums.freertos.org/t/sprintf-not-working-with-floating-point-after-scheduler-started/466 "2013-10-22T23:11:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 22, 2013, 11:11pm UTC](https://forums.freertos.org/t/sprintf-not-working-with-floating-point-after-scheduler-started/466/1 "2013-10-22T23:11:15Z")

</div>

**[harryw12](https://sourceforge.net/u/harryw12/)** wrote on [Tuesday, October 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/18452332/#54db):

Hi,  
porting FreeRTOS7.5.3 on PSOC5LP using PSOC Creator 3.0(newlib included).  
where I found sprintf not working with floating point(got all NULL chars except the ‘.’ after conversion) after FreeRTOS scheduler started (works before).

it looks like the newlib with PSOC Creator 3.0 might have the floating point funtion issue while in a multitasking env.  
newlib in PSOC Creator 3.0: the floating point functions works  
newlib in PSOC Creator 3.0 with FreeRTOS started: floating point functions does not work  
newlib in POSC Creator 2.1 with FreeRTOS started: floating point functions works

I don’t know if this is relating to reentrant of newlib (included in PSOC Creator 3.0). But I enabled the macro #define configUSE\_NEWLIB\_REENTRANT == 1 in FreeRTOSConfig.h, and memory allocation in the port is using heap2.c

Anyone can advise where to start on this issue? thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 23, 2013, 2:22am UTC](https://forums.freertos.org/t/sprintf-not-working-with-floating-point-after-scheduler-started/466/2 "2013-10-23T02:22:19Z")

</div>

**[harryw12](https://sourceforge.net/u/harryw12/)** wrote on [Wednesday, October 23, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/18452332/#dfe3):

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 23, 2013, 8:27am UTC](https://forums.freertos.org/t/sprintf-not-working-with-floating-point-after-scheduler-started/466/3 "2013-10-23T08:27:44Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, October 23, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/18452332/#d708):

This can happen if the stack is not correctly aligned to an 8 byte boundary - but the FreeRTOS code should ensure that it is. I have tried with configUSE\_NEWLIB\_REENTRANT set to 1 (should not make any difference to alignment) and heap2.c and find the stack is aligned as expected when the task starts.

I assume your FreeRTOS version is very new as configUSE\_NEWLIB\_REENTRANT was only introduced recently. Are you using V7.5.3 - as prior versions didn’t initialse the reent structures until the first context switch, maybe if you are using it prior to the first context switch you would get a problem resulting in a stack mishap?

Regards.
