char chunkdata[2] = {0};
uint16_t array_read[20] = {...};//initialized with some values
float32_t var;
chunkdata[0] = array_read[OFFSET] + (array_read[OFFSET+1] << 8);
chunkdata[1] = array_read[OFFSET+2] + (array_read[OFFSET+3] << 8);
var = *(float_t *)(&chunkdata[0]);
In the above code, the value of var is correct only if &chunkdata[0] has even value (chunk data is even aligned). But that depends on chance . If odd aligned address is supplied , then value of var is wrong. C28x decrements the address and then combines the value. __align() doesn't work for local variables according to compiler, so using it didn't help.
I want to split float into 4 8-bit chunks and join 4 8-bit chunks into float for EEPROM and CAN communication purposes. How to do it robustly? Also MISRA C compliance check is planned later. I am starting this post because I had marked previous post as resolved and now I can't undo it.
