USART float values
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-12-07 8:08 AM
Posted on December 07, 2012 at 17:08
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? #usart
Labels:
- Labels:
-
UART-USART
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-12-07 9:52 AM
Posted on December 07, 2012 at 18:52
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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-12-07 9:00 PM
Posted on December 08, 2012 at 06:00
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 terminalOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-12-08 5:43 AM
Posted on December 08, 2012 at 14:43
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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-12-08 8:41 AM
Posted on December 08, 2012 at 17:41
@clive1
thanks man! i1l check it out thanks a ton regards