IAP erase
2006-06-01 by lpc.lover
Hi all.
I write this code for erase flash of a LPC2106.
This code is base on some code I found on Internet.
I when to know what is a SectorStar? that resembles to?
Flash sector prepare give me a result of 7. What that mean?
Thank.
int EraseSectors(unsigned int SectorStart, unsigned int SectorEnd,
unsigned long ProcFrequency)
{
unsigned long command[5];
unsigned long result[2];
IAP iap_entry = (IAP) IAP_LOCATION;
__disable_interrupt();
command[0] = FLASH_PREPARE_SECTOR_TO_WRITE;
command[1] = SectorStart;
command[2] = SectorEnd;
command[3] = ProcFrequency;
iap_entry(command, result);
// result[0] always give me 7!!! I don't know what is this error.
if (CMD_SUCCESS == *result) {
command[0] = FLASH_ERASE_SECTORS;
iap_entry(command, result);
}
__enable_interrupt();
return (CMD_SUCCESS == *result);
}