I am a hardware man (former retired electronics engineer) who wants to extend his knowledge to embeded software. I am a newbie with C langage.
My LaunchPad equiped with a MSP430g2553 use a DS18B20 to measure temperature. This part of software works. I want to transmit via UART my temperature (which is a float)(celsius is a float) to my PC.
Here is my code:
while(1) { if(GO) // Button pressed { temperature=GetData(); celsius= temperature*.0625; sprintf(string,"%f degres\n\r",celsius); i=0; do { UCA0TXBUF = string[i++]; // send character i in Tx buffer while(!(IFG2 & UCA0TXIFG)); // Wait for TX buffer to be ready for new data } while(i<sizeof string-1); } }
sprint don't works and the result is only: " degres" on my PC !!!
Is there a method to convert a float into a string of characters ?