IAP flash erase not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

IAP flash erase not working

635 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by laser_scientist on Sat Dec 05 09:09:44 MST 2015
Hello. I am working with an LPC11E14 using the IAP routines to clear the last sector of flash, like this:

__disable_irq();

// Prepare to write/erase
command[0] = IAP_PREWRRITE_CMD;// Prepare to write/erase command code
command[1] = DATA_SECTOR_START;
command[2] = DATA_SECTOR_END;
iap_entry(command, result);

if(result[0] != IAP_CMD_SUCCESS)
return ERROR_SETUP;

// Erase
command[0] = IAP_ERSSECTOR_CMD;// Erase command code
command[1] = DATA_SECTOR_START;
command[2] = DATA_SECTOR_END;
iap_entry(command, result);

if(result[0] != IAP_CMD_SUCCESS)
return ERROR_ERASE;

// Re-enable interrupt mode
__enable_irq();


I expect the sectors from DATA_SECTOR_START to DATA_SECTOR_END to be clear (0xFF), but it's not getting erased, even though the result from both operations is successful. Has anyone seen this behavior, or have an idea of what might be happening? Thanks in advance for any assistance.
标签 (1)
0 项奖励
3 回复数

571 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by laser_scientist on Sat Dec 05 10:41:19 MST 2015
Thanks for the reply, I just discovered that. It was missing in the periph_flashiap_flashsig example I had pulled from.
0 项奖励

571 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by laser_scientist on Sat Dec 05 10:39:35 MST 2015
Okay, thanks to this post, I figured it out. The LPC flash write example was missing a key line in the erase call:

command[3] = SystemCoreClock / 1000;


So that block should be:

// Erase
command[0] = IAP_ERSSECTOR_CMD;// Erase command code
command[1] = DATA_SECTOR_START;
command[2] = DATA_SECTOR_END;
command[3] = SystemCoreClock / 1000;
iap_entry(command, result);

0 项奖励

571 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Sat Dec 05 10:37:58 MST 2015
The erase command requires the clock frequency in kHz specified as a parameter.
0 项奖励