PG1

Looking for clever way to store 32bit float constants in array to initialize byte-wide eeprom

Discussion created by PG1 on Jan 4, 2012
Latest reply on Jan 6, 2012 by PG1

I am doing alot of software testing and have written code to force data into a byte wide eeprom. Normally the EEPROM would be loaded by production support equipment from a hex file.

 

 The eeprom contains many types (byte, int, long, float, double) . I need to put some 32 bit floating point constants into the array, but how could I use a macro to split up the 4 bytes of the floating point to align to the natural size of the byte wide eeprom.

 

Hopefully this will clarify:

 

 

#define REV 0

#define PRODUCT_TYPE 0

#define PI 3.1415     //pi is a ieee754 32bit type

 

 

//This is the array which will be loaded into NVRAM for software testing purposes

 

const Byte gNVRAMInitialValues[ SIZE_OF_NVRAM ] =
                                         { REV, PRODUCT_TYPE, MSB_OF_PI, BYTE2_OF_PI, BYTE_3_OF_PI, LSB_OF_PI}; 

 

 

In other words, what is the macro definition for the four bytes MSB_OF_PI, BYTE2_OF_PI, BYTE_3_OF_PI, LSB_OF_PI which represent PI as an ieee754 32 bit

Outcomes