In using EEE of MC9S12XEG128, suppose that there is a wrong partition on D-Flash & Buffer RAM.
Partition-D-Flash command (which is an application level command) wants to reparation D-Flash.
Which command should be launch before Partition-D-Flash command?
Please note that since I’m using cyclonePro for programming micro, it is not possible to launch Erase-All-Block command (because of micro operating mode).
Please kindly review following initialization function and let me know if there is any problem.
Thank you.
bool ETK_boolEEPROMInit(void)
{
int8u dfPart, erPart;
while(!FSTAT_CCIF);
/* Set clock value */
FCLKDIV = FCLK_DIV_CFG;
while(!FSTAT_CCIF);
if(FCLKDIV != (FSTAT_CCIF_MASK | FCLK_DIV_CFG))
return EEPROM_INIT_FAIL;
LaunchEepromCommand(0,EEPROM_QUERY,0,0,0);
if((FSTAT!=FSTAT_CCIF_MASK)||(FERSTAT !=0x00))
return EEPROM_INIT_FAIL;
FCCOBIX = 1;
dfPart = FCCOBLO;
FCCOBIX++;
erPart = FCCOBLO;
if((erPart != EEE_RAM)||(dfPart != DFPART))
{
/* EEPROM hasn't been initialized yet */
LaunchEepromCommand(2, PARTITION_D_FLASH, 0, DFPART, EEE_RAM);
if((FSTAT!=FSTAT_CCIF_MASK)||(FERSTAT !=0x00))
return EEPROM_INIT_FAIL;
LaunchEepromCommand(0,EEPROM_QUERY,0,0,0);
if((FSTAT!=FSTAT_CCIF_MASK)||(FERSTAT !=0x00))
return EEPROM_INIT_FAIL;
FCCOBIX = 1;
dfPart = FCCOBLO;
FCCOBIX++;
erPart = FCCOBLO;
if((erPart != EEE_RAM)||(dfPart != DFPART))
return EEPROM_INIT_FAIL;
}
LaunchEepromCommand(0,ENABLE_EEPROM_EMULATION,0,0,0);
if((FSTAT!=FSTAT_CCIF_MASK)||(FERSTAT !=0x00))
return EEPROM_INIT_FAIL;
return EEPROM_INIT_DONE;
}