A question about read EEPROM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

A question about read EEPROM

跳至解决方案
1,092 次查看
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 项奖励
回复
1 解答
1,084 次查看
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 项奖励
回复
1 回复
1,085 次查看
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 项奖励
回复