AnsweredAssumed Answered

mc9s12g128 100pin  erase all eeprom commad

Question asked by 张 华荣 on Jun 2, 2015
Latest reply on Jun 4, 2015 by 张 华荣

When I call the below function,the all eeprom(0x400-0x13FF) is erased and the MCU reset.Please help me.

void Eep_EraseAllEeprom(void)

{     
     FSTAT =0x30U;                /*Before launching a command, the ACCERR and FPVIOL bits in the FSTAT registermust be clear*/

     FCCOBIX = 0x00U;

     FCCOB = 0x0900U;          /*the Erase flash block command is 0x09*/

     CCOBIX++;

     FCCOB = 0x0400;

     FSTAT =0x80U;                /*FSTAT register (to launch command)Clear CCIF 0x80*/

}

 

the Init function is below:

void Eep_Init(void)

{

  CLKDIV_FDIVLCK = 0x01U;

  FCLKDIV_FDIV = 0x18U;         

      

  FCNFG_CCIE =0x00U;            

  FCNFG_IGNSF = 0x00U;        

  FCNFG_FDFD = 0x01U;

  FCNFG_FSFD = 0x01U;

      

   FERCNFG_DFDIE = 0x00U;

   FERCNFG_SFDIE = 0x00U;

      

   FSTAT_CCIF = 0x01U;

   FSTAT_ACCERR = 0x01U;

   FSTAT_FPVIOL = 0x01U;

      

    FERSTAT_DFDIF = 0x01U;

    FERSTAT_SFDIF = 0x01U;

      

    DFPROT_DPOPEN = 0x01U;    /*disable protection*/

    DFPROT_DPS = 0x00U;

}

 

the Erase flash block is below

tttt.jpg

Outcomes