Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Looking for IAP example

2005-08-03 by Mark Butcher

Hi IAP is very easy on the LPC21xx

Here's an example of how to erase sectors:
                                    

/********************************************************/

#define IAP_LOCATION 0x7ffffff1

#define CMD_SUCCESS  0

#define FLASH_PREPARE_SECTOR_TO_WRITE     50
#define FLASH_ERASE_SECTORS               52

typedef void (*IAP)(unsigned long [], unsigned long []);

int fnEraseSectors(unsigned char SectorStart, unsigned char 
SectorEnd, unsigned long ulProcFrequency)
{
  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] = ulProcFrequency;

 iap_entry(command, result);

 if (CMD_SUCCESS == *result) {
   command[0] = FLASH_ERASE_SECTORS;
   iap_entry(command, result);
 }
 __enable_interrupt(); 

  return (CMD_SUCCESS == *result);
}

Notes:
1. when the IAP routine is called, the processor switches 
automatically to thumb instruction set since the address is odd.
2. Here interrupts are disabled during the IAP calls. since the 
FLASH can not be used during IAP processing. If interrupts are 
required to be serviced during IAP, the interrupt routines must be 
in RAM.
3. Note that the present operating frequency has be be passed as a 
parameter to ensure that the deletion or programming is performed 
correctly. By using a variable the routine can be used even when the 
PLL is varied (eg. switching between full speed and slower 
operation).
4. Commands and details about error codes which can be returned are 
all in the LPC21xx data sheet.

Regards

Mark Butcher

www.mjbc.ch




--- In lpc2000@yahoogroups.com, "r_bottleneck" <r_bottleneck@y...> 
wrote:
> Hi,
> 
> Does anybody know a source where to find a IAP program example ?
> 
> I'm not yet familiar with the LPC21xx family and I would like to 
> use that feature in a new project.
> 
> Thank you for any hint.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.