Hi
I am trying to make a routine for updating my firmware without using ISP. So fare I am downloading my firmware to a free location in FLASH and I am now trying to copy this firmware to the first part of the FLASH memory. I am aware that to do this, the function copying the firmware cannot also be in the FLASH section being written to, so I am trying to place this function in RAM using __RAMFUNC. I have attached the code for my function below. However, I am experiencing that the execution is halted after executing the "Erase sectors" IAP command. So it seems to me that the code is not executed from RAM. Anyone have any idea of what I am doing wrong? (I am using LPC1549)
__RAMFUNC(RAM2) void flashing(uint8_t sectors)
{
unsigned int command[5];
unsigned int result[4];
typedef void (*IAP)(unsigned int[], unsigned int[]);
IAP iap_Entry = (IAP) IAP_LOCATION;
uint8_t ret_code,i;
uint16_t ii;
uint8_t data[1024];
__disable_irq();
command[0] = IAP_PREWRRITE_CMD;
command[1] = 0;
command[2] = sectors;
iap_entry(command, result);
command[0] = IAP_ERSSECTOR_CMD;
command[1] = 0;
command[2] = sectors;
command[3] = SystemCoreClock / 1000;
iap_entry(command, result);
for(i=0;i<sectors*4;i++)
{
for(ii=0; ii<1024;ii++)
{
data[ii] = *(uint8_t*)(START_ADDR_SECTOR+i*1024+ii);
}
command[0] = IAP_PREWRRITE_CMD;
command[1] = 0;
command[2] = sectors;
iap_entry(command, result);
command[0] = IAP_WRISECTOR_CMD;
command[1] = i*1024;
command[2] = (uint32_t) &data;
command[3] = 1024;
command[4] = SystemCoreClock / 1000;
iap_entry(command, result);
}
NVIC_SystemReset();
}