AnsweredAssumed Answered

LPC2294: IAP call #50 always fails for flash sector #17 (the last one) !!??

Question asked by gtrevi on Feb 2, 2017
Latest reply on Feb 23, 2017 by CarlosCasillas
Branched to a new discussion

Hello all,

 

I'm experiencing a very nasty issue calling IAP function #50 (IAP_CMD_PREPARE_SECTORS_FOR_WRITE): simply, works like a charm for any flash sector interval as far as sector 17 (the last one for LPC2294) is not included, in that case I always get error #7 - INVALID_SECTOR (which does not make sense since LPC2294 *does* have sectore #17, which's address range is 0x0003 E000 - 0x0003 FFFF).

 

Here's my code:

 

#define BOOT_CPU_SYSTEM_SPEED_KHZ       (60000)

#define IAP_CLOCK_KHz (BOOT_CPU_SYSTEM_SPEED_KHZ)
#define IAP_ADDRESS 0x7FFFFFF1


unsigned int param_table[5] = {0,0,0,0,0};
unsigned int result_table[3] = {0,0,0};
typedef void (*IAP)(unsigned int [],unsigned int[]);
IAP iap_entry = (void (*)(unsigned int [],unsigned int []))IAP_ADDRESS;

 

#define IAP_CMD_PREPARE_SECTORS_FOR_WRITE   50

unsigned long iap_prepare_sector(unsigned long start_sector, unsigned long end_sector)
{
   if (end_sector < start_sector)
      return IAP_STA_INVALD_PARAM;

   param_table[0] = IAP_CMD_PREPARE_SECTORS_FOR_WRITE; 
   param_table[1] = start_sector;
   param_table[2] = end_sector;
   param_table[3] = IAP_CLOCK_KHz;
   iap_entry(param_table, result_table);

   

   return result_table[0];
}

 

Can anyone please help me explain why is this happening?

 

Many thanks!

G

Outcomes