cancel
Showing results for 
Search instead for 
Did you mean: 

how to send float values on uart using cubemx HAL_UART fucntion

HARI krishna
Associate II
Posted on February 27, 2017 at 14:07

Hi all,

 i am using GPS module in the project interfaced to the stm32f0 MCU. Everything working fine but how to send the float values of long&latt on the uart .

i tires replies in community but no luck. is there any setting needs to do in the compiler?

Compiler:Atollic truestudio.

Stm32cubeMx code generator.

3 REPLIES 3
S.Ma
Principal
Posted on February 27, 2017 at 14:25

There were some similar thread on how to put the right compile options to printf on the debugger SWO line some floating data recently.

Otherwise, in

https://community.st.com/0D50X00009XkVtcSAF

there is an example of simple printf using bit fractional (for example 'printf('%M', 123456); which will output 3456 as easy to use string. More of a pseudo float without needing it and its library in the memory space.

LMI2
Lead
Posted on February 27, 2017 at 18:55

Any Uart sends or receives only bytes, that is 8bit integers. No floats. I would send something like X12.3456Y. So that the receiving SW can be absolutely sure where the number starts and ends.

To be exact: UARTS can send and receive something like 4-9bit integers but not all.

Posted on February 27, 2017 at 19:08

A 32-bit float is inadequate to represent latitude and longitude accurately/consistently. 

Send them as a stream of bytes? The computer should have a common understanding of the IEEE formats used here. Presumably you want to send them in a compact machine readable fashion, not an ASCII human readable one?

Data representation in memory is a pretty basic tenet of computer science. You should review the representation of bytes, and words, and floating point numbers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..