float to ASCII conversion in PSoC 3's Keil Compiler | Cypress Semiconductor
Support & Community
float to ASCII conversion in PSoC 3's Keil Compiler
Is ftoa function available in PSoC Creator (Keil) as it was available in PSoC Designer(ImageCraft)?
ftoa function is not available in PSoC Creator. Here we have sprintf, which does the same job. This function is very similar to printf, which prints formatted data to stdout. But sprintf print formatted data to string.
So, to do float to ASCII conversion, following is sample code:
float myFloat = 784.4564549;
bytesWritten = sprintf(myString, "%f", myFloat);
myFloat is the number which has to be converted to ASCII. sprintf returns the number of bytes written to array. Here return value will be stored in bytesWritten. myString will contain ASCII string after conversion.
The function prototype for the sprintf function is present in 'stdio.h' header. So, remember to include this header in the source file that calls the sprintf function.