#ifdef __USE_CMSIS #include "LPC17xx.h" #endif #include <cr_section_macros.h> #include <NXP/crp.h> __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; #define IAP_LOCATION 0x1FFF1FF1 unsigned int command[5]; unsigned int result[5]; typedef void (*IAP)(unsigned int [],unsigned int[]); IAP iap_entry; int main(void) { SystemCoreClockUpdate(); command[0] = 50; command[1] = 26; command[2] = 26; iap_entry (command,result); while(1) { } return 0 ; } |
Setting function pointer:
"iap_entry=(IAP) IAP_LOCATION;"
is missed in the code
write this before main.
#ifdef __USE_CMSIS #include "LPC13Uxx.h" #endif #include <cr_section_macros.h> #include <NXP/crp.h> __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; #define IAP_LOCATION 0x1fff1ff1 #define ADDRESS0xC000 typedef void (*IAP)(uint32_t [],uint32_t []); IAP iap_entry = (IAP) IAP_LOCATION; int main(void) { uint32_t command[5]; uint32_t result[4]; uint8_t msg[] = "TEST IAP"; // *** PREPARE SECTOR 12 command[0] = 50; command[1] = 12; command[2] = 12; iap_entry(command, result); // *** ERASE SECTOR 12 command[0] = 52; command[1] = 12; command[2] = 12; command[3] = SystemCoreClock / 1000; iap_entry(command, result); // *** PREPARE SECTOR 12 command[0] = 50; command[1] = 12; command[2] = 12; iap_entry(command, result); // *** COPY RAM TO FLASH command[0] = 51; command[1] = (uint32_t)ADDRESS; command[2] = (uint32_t)&msg; command[3] = 256; command[4] = SystemCoreClock / 1000; iap_entry(command, result); while(1) { } return 0 ; } |