HCS12XEP100 erase D-FLASH error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HCS12XEP100 erase D-FLASH error

Jump to solution
845 Views
jasoncui
Contributor II

Hi, all

 

When I tried to erase d-flash of hcs12xep100 with ERASE_D_FLASH_SECTOR(0x12) command, ACCERR error was always emerging. Does anybody can point out what's the problem of my code? Does the eeprom can only be used as partition EEE? Any help would be greatly appreciated! The code is pasted as follows:

 

void DFlash_Init(void)

{

   while(FSTAT_CCIF==0);            //等待正在处理的FLASH操作完成

   FCLKDIV=0x07;                    //外部晶振为8M.FLASH时钟不超过1M,具体参照手册

   FCNFG=0x00;                      //禁止中断

   while(FCLKDIV_FDIVLD==0);        //等待时钟设置成功

}

 

void DFlash_Erase(word ADDR16)

{

  while(FSTAT_CCIF==0);

  if(FSTAT_ACCERR)           //判断并清除标志位;

      FSTAT_ACCERR=1;

  if(FSTAT_FPVIOL)           //判断并清除标志位;

      FSTAT_FPVIOL=1;

 

  FCCOBIX_CCOBIX=0x00;

  FCCOB=0x1210;           //写入擦除命令和高位地址

  FCCOBIX_CCOBIX=0x01;

  FCCOB=ADDR16;           //写入低16位的地址

  FSTAT_CCIF=1;           //启动执行命令

  while(FSTAT_CCIF==0);   //等待执行完成

}

 

void main(void)

{

    DFlash_Init();                  //初始化Flash

    DFlash_Erase(data_Address);     //确保先擦除后写入

 

  for(;;)

  {

  }

}

Labels (1)
0 Kudos
1 Solution
621 Views
RadekS
NXP Employee
NXP Employee

Hi Jason,

Please look at Table 24-68. Erase D-Flash Sector Command Error Handling in RM. There is list of Error Condition which causes setting of ACCERR error bit.

So, I could see two basic potential root causes in your case:

  1. The ADDR16 may be not aligned. The lowest bit in ADDR16 must be 0 (global address [0] = 0).
  2. The global address [22:0] points to the D-Flash part which is already partitioned for EEE.

The (Full) Partition command typically runs on MCU just once. If we want change that settings, we have to use Erase All Blocks command (0x08) for removing information about partitioning (only in special mode). The simplest way how to execute Erase All Blocks command is calling Unsecure procedure:

In CodeWarrior debugger menu ->MultilinkCyclonePro ->Unsecure…

If not work you can use unsecure12 from P&E:

http://www.pemicro.com/downloads/download_file.cfm?download_id=16

Unsecure_12 Help Files:

http://www.pemicro.com/downloads/download_file.cfm?download_id=14

Note: For downloading is necessary registration. The Unsecure12 tool work only for Pemicro debuggers.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
4 Replies
622 Views
RadekS
NXP Employee
NXP Employee

Hi Jason,

Please look at Table 24-68. Erase D-Flash Sector Command Error Handling in RM. There is list of Error Condition which causes setting of ACCERR error bit.

So, I could see two basic potential root causes in your case:

  1. The ADDR16 may be not aligned. The lowest bit in ADDR16 must be 0 (global address [0] = 0).
  2. The global address [22:0] points to the D-Flash part which is already partitioned for EEE.

The (Full) Partition command typically runs on MCU just once. If we want change that settings, we have to use Erase All Blocks command (0x08) for removing information about partitioning (only in special mode). The simplest way how to execute Erase All Blocks command is calling Unsecure procedure:

In CodeWarrior debugger menu ->MultilinkCyclonePro ->Unsecure…

If not work you can use unsecure12 from P&E:

http://www.pemicro.com/downloads/download_file.cfm?download_id=16

Unsecure_12 Help Files:

http://www.pemicro.com/downloads/download_file.cfm?download_id=14

Note: For downloading is necessary registration. The Unsecure12 tool work only for Pemicro debuggers.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
621 Views
jasoncui
Contributor II

Hi RadekS

Thanks for your kind reply!

Sorry for missing the definition of "data_Address". Actually, the value of "data_Address" is 0x0. And I did not partition any D-Flash part for EEE,

so the two potential root cause you mentioned are not the cause of the error. However, I took your advice, executed Erase all blocks command by calling Unsecure, the "ACCERR' error didn't appear again. I tried erase another new chip(not used before), firstly, the "ACCERR" is happened, after executed Unsecure, the error is disappeared. Does the chip should be "unsecured" at first time used? And is there other simple way to do this?

Regards

0 Kudos
621 Views
RadekS
NXP Employee
NXP Employee

Hi Jason,

Thank you for more details and I am glad, that it works now.

Yes, I suppose that MCUs were already partitioned before your first use. That is strange because we typically delivery MCUs fully erased.

Anyway, the complete erase of MCU prior first programming is a good habit.

This potential root cause could be simply checked at MCUs by setting EEEIFRON bit in MMCCTL1 register and checking global addresses 0x120000 – 0x120007. There are stored DFPART and EFPART values and their copies. It will be set to 0xFFFF… when you execute mass erase command.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
621 Views
jasoncui
Contributor II

Hi RadekS

Thanks a lot.

Regards

0 Kudos