5 Replies Latest reply on Sep 29, 2016 12:26 AM by evan.d

    Sending floats across SPI

    evan.d

      Hi,

         

      I have used some sample code to send a float across an SPI connection. To reconstruct the float from a buffer I have used a union.

         

      union{
          float floatx;
          int8 b[4];    
          } x;

         

      x.b[0] = rxBuffer[4];
      x.b[1] = rxBuffer[3];
      x.b[2] = rxBuffer[2];
      x.b[3] = rxBuffer[1];

         

      but when I compare the value sent to the value of x  (x.floatx == -9.9999) they aren't the same even thought the bytes printed on the LCD look correct (in hex). Have I done this correctly?

         

      Thanks