A question about read EEPROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A question about read EEPROM

Jump to solution
913 Views
Monke
Contributor I

I CAN write and read EEPROM correctly in debug mode,but when I download the software again,the data I Writen into EEPROM will be lost,all  of the datas becomes to 0xFF,what happened?

 

My chip is MC9S12ZVMC12,this is my code:

EEPROM_Init(0x05);// 6.25MHz busclk

//.........................................
// check whether flash is erased and potentially erase it.
//.........................................

for(addrl=0x100000UL; addrl<=0x10007FUL; addrl+=4) // entire sector
{
if(EEPROM_Erase_Verify_Section(addrl,4) == NON_ERASED)
{
err = EEPROM_Erase_Sector(addrl);
}
}

//.........................................
// write the flash per words
//.........................................

for(addrl=0x100000UL; addrl<=0x10003FUL; addrl+=2)
{
err = EEPROM_Program(addrl, buffer, 1);
}

//.........................................
// write the flash per multiple words
//.........................................

for(addrl=0x100040UL; addrl<=0x10007FUL; addrl+=8)
{
err = EEPROM_Program(addrl, buffer, 4);
}

//.........................................
// read the flash
//.........................................

for(addrl=0x100000UL; addrl<=0x10007FUL; addrl+=2)
{
data = EEPROM_Read_Word(addrl);
}

0 Kudos
1 Solution
905 Views
ArchieLuo
Contributor III

Hello ,you need to set "preserve range". If you did not set this parameters,it will erase all sectors while flash programming the chip。

ArchieLuo_0-1640488576957.png

 

View solution in original post

0 Kudos
1 Reply
906 Views
ArchieLuo
Contributor III

Hello ,you need to set "preserve range". If you did not set this parameters,it will erase all sectors while flash programming the chip。

ArchieLuo_0-1640488576957.png

 

0 Kudos