I am writting the driver about D-flash of mc9s12xep100, when i refered to the datasheet, it said : "A Flash word must be in the erased state before being programmed.", BUT How to verify a D-Flash word in the erased state?
unsigned char DFlash_Erase_check(word ADDR16, unsigned char N_words)
{
while(FSTAT_CCIF==0);
if(FSTAT_ACCERR)
FSTAT_ACCERR=1;
if(FSTAT_FPVIOL)
FSTAT_FPVIOL=1;
FCCOBIX_CCOBIX=0x00;
FCCOB = 0x1010;
FCCOBIX_CCOBIX=0x01;
FCCOB = ADDR16;
FCCOBIX_CCOBIX=0x10;
FCCOB = N_words;
FSTAT_CCIF=1;
while(FSTAT_CCIF==0);
if(FSTAT_ACCERR == 1)
return 1; //Error
else
return 0; //OK
}
Is there some flags can be checked for it?