Content originally posted in LPCWare by brattchess on Tue Jan 05 09:19:07 MST 2016
Hello,
I am testing the IAP Commands en la lpcxpresso without problems, all is working right.
when I pass the code to my board, the code is not working, it is like the code stops because the watchdog restarts the program.
RAM RamLoc8 0x100000C0 0x1F20
/*
* The IAP funtion address in LPC11xx ROM
*/
#define IAP_ADDRESS 0x1FFF1FF1
/*
* Command codes for IAP
*/
#define PREPARE_SECTOR 50
#define COPY_RAM_TO_FLASH 51
#define ERASE_SECTOR 52
#define BLANK_CHECK_SECTOR 53
#define READ_PART_ID 54
#define READ_BOOT_CODE_REV 55
#define COMPARE 56
#define REINVOKE_ISP 57
#define READ_UID 58
typedef unsigned int (*IAP)(unsigned int[], unsigned int[]);
static const IAP iap_entry = (IAP) IAP_ADDRESS;
***
__disable_irq();
_iap_powerfail(dataTosave,iniFlash);
__enable_irq();
***
void _iap_powerfail(uint8_t* vBuf, uint32_t vIniPos){
// TODO: insert code here
__e_iap_status iap_status;
// Init the IAP driver
iap_init();
// Prepare the sector for writing
iap_status = (__e_iap_status) iap_prepare_sector(CONFIG_FLASH_SECTOR,(CONFIG_FLASH_SECTOR + CONFIG_FLASH_SECTOR_SIZE));
while( iap_status != CMD_SUCCESS ){
iap_status = (__e_iap_status) iap_prepare_sector(CONFIG_FLASH_SECTOR,(CONFIG_FLASH_SECTOR + CONFIG_FLASH_SECTOR_SIZE));
}
// write data to flash
iap_status = (__e_iap_status) iap_copy_ram_to_flash((void *)vBuf,(void *)vIniPos, 256);
while( iap_status != CMD_SUCCESS ){
iap_status = (__e_iap_status) iap_copy_ram_to_flash((void *)vBuf,(void *)vIniPos, 256);
}
}
Any idea?
Is it possible that SYSAHBCLKCTRL.Flasharray will be necessary ?
Thanks in advance.