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);
}
已解决! 转到解答。