You are here

Converting float to char [] to print in UART. | Cypress Semiconductor

Converting float to char [] to print in UART.

Summary: 3 Replies, Latest post by Bob Marlowe on 05 Oct 2016 11:50 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
user_459156114's picture
User
35 posts

This seems extremely trivial but I'm trying to convert a float to the char [] so I can print it out in UART. Here is how I'm trying to achieve this: 

char buff[10];
float test = 2.32
sprintf(buff, "%f", test);
UART_UartPutString(buff);

However doing this nothing is printing out...The above is what i've seen on all the examples :,( why isn't this working for me. 

user_1377889's picture
User
10708 posts

As I stated in another of your threads: To use sprintf for floats you need to set

Use newlib nano

Use newlib nano float formatting

Heap size 0x0200

 

Bob

 

user_459156114's picture
User
35 posts

You're right, I apologize. I'm so in over my head trying to get this project to work I miss some things.

Does the heap size have to be that exactly? Or at least 0x0200? 

side note: I deeply deeply appreciate all you're help. 

user_1377889's picture
User
10708 posts

I did not take the time to find out the minimum value, but 0x0200 seem to be large enough for heap.

 

Bob

Log in to post new comments.