2012-12-07 08:08 AM
hello,
ive been playing around with USART on my stm32f4 discovery for some time now. I am able to send letters and strings on USART but not float values. i really need to transmit float values to PC.I`ve tried but failed.used sprintf() also without luck..can anyone tell me how could i send float values over USART? #usart2012-12-07 09:52 AM
How does sprintf() fail? Are you linking in a library that supports floating point via printf()?
On a simplistic level you could output the integer and fractional parts with some decimal math.2012-12-07 09:00 PM
hi clive,
yes i`ve tried splitting number onto individual digits and sensing them converting to ascii characters.I`ve been using coocoxcoide 1.6..i guess ive added retarget printf option and the code, float pi=3.1417; char buffer[64]; sprintf(buffer,''%f'',pi); int i=0; while(buffer[i]!='\0') { USART_SendData(USART1,buffer[i]); delay(0x000FFFFF); } but i dont get any output on terminal2012-12-08 05:43 AM
Ok, the USART has a status register that indicates if it's empty (TXE), use it, and not arbitrary delays.
If you don't see output perhaps your not generating any string, you could brace the output of the string with '[' and ']' to confirm this. Use a debugger and look at the string. If the CooCox default library and settings is not supporting floats in printf/scanf then find the settings and libraries to enable that. Read the documentation, access their support resources and forum.2012-12-08 08:41 AM
@clive1
thanks man! i1l check it out thanks a ton regards