title: copying data to data structure using memcpy
body: <p>I'm trying to read data from EEPROM, and I have three structs. </p>
  
  <pre><code>typedef struct
  {
      fract32 MechCoilPhiBase;    // Mech Angle Table
      fract32 MechCoilPhi3rd;    // Mech Angle Table
      fract32 PhiSaltwater;       // Saltwater Table
      UINT16  d;
      UINT16  crc;
  } ChannelData_T;
  
  typedef struct
  {
  
      UINT32 reHarmonic;
      UINT32 reFundamental;
      UINT32 imgHarmonic;
      UINT32 imgFundamental;
  
      UINT16 crc;
  } CoilBoard_T;
  
  // mechanic angles and salt water angles of coil stored in coil-eeprom
  typedef struct
  {
      ChannelData_T channel[NUM_CHANNELS];
      CoilBoard_T   coilboard;
  //  UINT32    gCoilSerialNumber;
  //  UINT32    gInversSerialNumber;
  } Coil_Eeprom_Data_T;
  </code></pre>
  
  <p>I'm trying to read the data, but the size is not a power of 2, I tried to padding the data, but the struct is not filled correctly. </p>
  
  <p>I'm using the following code to read the data from the buffer, and fill it with the struct. 
  For example the crc variable is 0, and its not read correctly from the buffer.</p>
  
  <p>here is how I copy the data to the buffer</p>
  
  <pre><code> memcpy( (void*) &amp;CoilEepromData, (const void*) &amp;EepromCoil.aRxData[0], sizeof(Coil_Eeprom_Data_T) );
  
  
  
  extern volatile Coil_Eeprom_Data_T  CoilEepromData; 
  extern volatile Eeprom_Coil_T       EepromCoil;                         // control struct for the coil-eeprom  
  
  
  typedef struct
  {   
      UINT8   crcValueOut;
      UINT8   crcValueIn; 
  
      UINT8   pageAddress; 
      UINT8   dataLength;
  
      UINT8   bytesToTransmit;
      UINT8   bytesWritten;
  
      UINT8   bytesToReceive;    
      UINT8   bytesRead;    
  
      UINT8   errorCount;     
      bool    bWriteSucceed:1;
      bool    bStartup:1;  
      bool    bReadingStarted:1;
      UINT8   aTxData[COIL_SPI_BUFFER_SIZE];
      UINT8   aRxData[COIL_SPI_BUFFER_SIZE];
  } Eeprom_Coil_T;
  </code></pre>