2021-10-06 10:39 AM
Hi,
I am trying to send and receive the float variable between STM32H745 and my PC. I can only transmit and receive strings. Is it even possible to handle any type of data rather than string.
Thank you.
2021-10-06 11:25 AM
The chip doesn't care how you're interpreting data bytes. Treat the value as raw data and cast it to uint8_t pointer.
float value = 123.4f;
TransmitData((uint8_t *) &value, 4);
Do the reverse on the PC:
float value = 0.0f;
ReceiveData((uint8_t *) &value, 4);
2021-10-06 11:41 AM
All just a collection of bytes. Data Representation 101
Typically using IEEE-754 data format for float/double variables. Mantissa/Exponent forms.
https://en.wikipedia.org/wiki/IEEE_754