David LECOMTE

Copy Flash Param to structure in RAM

Discussion created by David LECOMTE on Apr 28, 2011
Latest reply on Apr 28, 2011 by kef

Hello,

I use  MC9S08QE8 and i reseved the first page like zone that contains parameters values.

Today,  at the start up i fill my structure (in RAM) to reading each octet Flash zone with Flash Module (see follow)

 

for(i=0;i<NbSegment;i++)
    {
       
        ParamCalibration.ValZ[i] =flash_read(CoefZ1+(i*2))<<8;
        ParamCalibration.ValZ[i] +=flash_read(CoefZ1+(i*2)+1);
       
        ParamCalibration.ValG[i] =flash_read(CoefG1+(i*2))<<8;
        ParamCalibration.ValG[i] +=flash_read(CoefG1+(i*2)+1);
       
        ParamCalibration.SegConvertPression[i] =flash_read(CoefSegCP+(i*2))<<8;
        ParamCalibration.SegConvertPression[i] +=flash_read(CoefSegCP+(i*2)+1);
       
         
    }

 

char flash_read(unsigned int address)
{
  unsigned char *pointer;
  pointer = (char*) address;
  return (*pointer);
}

 

But my structure is big and i would like if a specific code it is possible to fill my structure with one or two instruction of the kind:

struct{

byte param1

long param2

int param3

} MyStruct;

MyStruct = @0xE000;

 

Thanks a lot

David

Outcomes