CW 5.9.0
My project is doing quite well so far, but I need to extract the data from the MCU so that it can be manipulated on in MS Excell.
To do this, I've decided to convert the data into a character string, and then send it over the SCI module into HyperTerm for extraction.
So far I have been searching for a standard C function that will do something like this, but so far I've only come up with printf.
I've got a notion that I'll probably end up doing this manually, though...
Solved! Go to Solution.
what about sprintf ?
Thanks kef,
That seems to work for the most part...
After I've spent a bit of time looking over the formatting options, I've managed to get it to output whats inside the format string... all except for the floating point number that is!
char cString[64]; // String bufferint n; // Size of string in the bufferfloat x; // Test numbervoid main(void){ MCUinit(); // Initialize device SCI1CR2 |= SCI1CR2_TE_MASK // Enable Xmit x = 1.2345; n = sprintf( cString, "The number is %g.", x); putString(cString); // Use recursion to output over SCI1 asm(SWI); // Halt program and return to BDM}
I've tried different % flags and options, but didn't get anything. cString still has only "The number is ."
Hey kef, figured out that I forgot to include a library that actualy supports floating point.
Hi AirDragon,
I have exactly the same problem. I can not convert float data to string by sprintf function. what library did you include to your project? I added float.h but didn't help!
Many thanks, bigmac!
That'll definantly come in handy when I get around to making the project use fixed point arithmetic...