Converting float to char [] to print in UART.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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. 

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

View solution in original post

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes