I write a structure into EEPRM as follows

typedef struct
   fract32 AmpF; // amplitude fundamental
   fract32 AmpH; // amplitude harmonic 
   UINT32 b;
   UINT16 d;
   UINT16 crc;


// mechanic angles and salt water angles of coil stored in coil-eeprom
typedef struct
    ChannelData_T     channel[NUM_CHANNELS];
    CoilBoard_T       coilboard;
    CoilBoardAmp_T    coil_h;
    CoilBoardAmp_T    coil_d;
//  UINT32    gCoilSerialNumber;
//  UINT32    gInversSerialNumber;
} Coil_Eeprom_Data_T;

I set that data by a software, which writes to that structure.

The problem is when reading that structure at the first time without writing to it, I read false data.

I need to detect that point. How would I know If the data that is read is false, or how would I know that I read the data without the software.


Add checksum or crc in Coil_Eeprom_Data_T structure. And verify it after reading the data from EEPROM.


Not the answer you're looking for? Browse other questions tagged or ask your own question.