UM10360 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2013. All rights reserved.
User manual Rev. 3 — 19 December 2013 632 of 841
NXP Semiconductors
UM10360
Chapter 32: LPC176x/5x Flash memory interface and programming
32.8 IAP commands
For in-application programming the IAP routine should be called with a word pointer in
register r0 pointing to memory (RAM) containing command code and parameters. The
result from the IAP command is returned in the table pointed to by register r1. The user
can reuse the command table for the result by passing the same pointer in registers r0
and r1. The parameter table should be large enough to hold all of the results in case the
number of results are greater than the number of parameters. Parameter passing is
illustrated in the Figure 138
. The number of parameters and results vary according to the
IAP command. The maximum number of parameters is 5, passed to the "Copy RAM to
Flash" command. The maximum number of results is 4, returned by the "Read device
serial number" command. The command handler sends the status code
INVALID_COMMAND when an undefined command is received. The IAP routine resides
at location 0x1FFF 1FF0.
The IAP function could be called in the following way using C.
Define the IAP location entry point. Bit 0 of the IAP location is set since the Cortex-M3
uses only Thumb mode.
#define IAP_LOCATION 0x1FFF1FF1
Define data structure or pointers to pass IAP command table and result table to the IAP
function:
unsigned long command[5];
unsigned long output[5];
or
unsigned long * command;
unsigned long * output;
command=(unsigned long *) 0x...
output= (unsigned long *) 0x...
Define a pointer to function type, which takes two parameters and returns void. Note the
IAP returns the result with the base address of the table residing in R1.
typedef void (*IAP)(unsigned int [],unsigned int[]);
IAP iap_entry;
Setting function pointer:
iap_entry=(IAP) IAP_LOCATION;
Whenever you wish to call IAP you could use the following statement.
iap_entry (command, output);
The IAP call could be simplified further by using the symbol definition file feature
supported by ARM Linker in ADS (ARM Developer Suite). You could also call the IAP
routine using assembly code.