This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430G2553: sprintf doesn´t work when I try to generate a +15 characters from float variables

Part Number: MSP430G2553

Tool/software: Code Composer Studio

Hello everyone.

I´m using MSP430G2553.

The purpose of my application is reading 3 analog inputs (P1.3 - P1.5) then send their values to UART comunication, I set the SMCLK to 16MHz, and I am using UART interruptions to do

the application and Baud Rate 9600.

My problem is when I want to generate the array char greater than 15 leght by sprintf. I save the char values in an exact lenght array for the 3 values, I used letters to separate them.

For example: if the analog inputs read the next values: A3 = 1.2732; A4 = 3.2781; A5 = 0.3321; and there is an array to save the characters char[19] s ={};


I used sprintf to generate the "string"

sprintf(s, "%.3fa%.3fb%.3f\n\r",A3, A4, A5);

 

But when I sendI have this outcome in the terminal: 1.000a1.000b1.000

I changed the Baud Rate up to 115200 but I have the same issue.

 

When I reduce the lenght to 15 I have this outcome: 1.273a3.278b0.3 but of course I can´t send all the characters

Someone could explain this and have a solution for this problem.

Regards.