A question about read EEPROM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

A question about read EEPROM

ソリューションへジャンプ
984件の閲覧回数
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 解決策
976件の閲覧回数
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 返信
977件の閲覧回数
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 件の賞賛
返信