0

I want to transmit float data from matlab gui to pic16f877A using uart. i went through google and got some examples but i am not able to understand exactly how 4bytes(float) be transmitted to pic and inside pic how to recombine those 4 bytes to read a float data.Is there a simple way to understand the transmission of float .

dcmotor
  • 58
  • 1
  • 12

1 Answers1

0

UART transmission is always made by sending bytes (byte array) one by one. So basically you need to convert your float number to four raw bytes. Keep in mind that float is already written (in memory) as four bytes. So if you make byte pointer to location of your float variable and take for bytes from that address you will get four bytes of your float number. Next what you need to do is to transmit byte per byte over UART. When you have byte array received on PIC side you can make float pointer to address of first byte of your array and get the value.

I hope this helps.

Also, please check following link which solves similar issue

C Function to Convert float to byte array

Community
  • 1
  • 1
Darko Djuric
  • 754
  • 4
  • 10