How do I send a float data by SPI?

Hi,

I am trying to send a float data with a length of 32 bit in PLECS coder between two launchpads f28379D by SPI communication. As I warned, the register of SPI only support a data 16 bit and I have to implement two C-scripts. The first C-script to split the data float in two packets of 16 bit, and the second one is used to receive the same packet and restore the data float in the other end (a review of their code you can review the file attached named “C_float2bit”).

But when I try to implement the SPI communication to the transmission of two float data, two sinusoids, (one green and one red), just only the second data (red) is received by the slave (or Master) and the green signal replicates the red signal, e.i, are equivalent by phase and amplitude.

My question is Do you know how to fix that or why that happen? I attached the file model named “prueba SPI 28379D master-slave with float data 2” for more information.

C_float2bit.plecs (14.8 KB)

prueba SPI 28379D master-slave with float data 2.plecs (157 KB)

Hi Efrain,

As I explained it to you in the email, the problem is with your C-script block for packing and unpacking the float. Use the attached blocks instead.

Regards,
Manu

FloatPacking.plecs (10.3 KB)