EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Looking for IAP example

Started by r_bottleneck August 3, 2005
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.


An Engineer's Guide to the LPC2100 Series

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@lpc2..., "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.



Mark,

Thank you very much. I appreciate your help.
It's a good explanation and starting point for IAP stuff.

Regards
--- In lpc2000@lpc2..., "Mark Butcher" <M_J_Butcher@I...>
wrote:
> 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@lpc2..., "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.




Memfault Beyond the Launch