UM11029
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2017. All rights reserved.
User manual
Rev. 1.0 — 16 June 2017
38 of 515
NXP Semiconductors
UM11029
Chapter 5: LPC84x ISP and IAP
5.6 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 of the IAP command is returned in the result table pointed to by register r1. The user
can reuse the command table for result by passing the same pointer in registers r0 and r1.
The parameter table should be big enough to hold all the results in case the number of
results are more than number of parameters. Parameter passing is illustrated in the
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 5, returned by the "ReadUID" command. The
command handler sends the status code INVALID_COMMAND when an undefined
command is received. The IAP routine resides at location 0x0F001FF0 and it is thumb
code, therefore called as 0x0F001FF1 by the Cortex-M4 to insure Thumb operation.
The IAP function could be called in the following way using C:
Define the IAP location entry point. Since the least significant bit of the IAP location is set
there will be a change to Thumb instruction set if called by the Cortex-M4.
Define data structure or pointers to pass IAP command table and result table to the IAP
function:
unsigned int command_param[5];
unsigned int status_result[5];
or
unsigned int * command_param;
unsigned int * status_result;
command_param = (unsigned int *) 0x...
status_result =(unsigned int *) 0x...
Define 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 the function pointer:
#define IAP_LOCATION *(volatile unsigned int *)(0x0F001FF1)
iap_entry=(IAP) IAP_LOCATION;
To call the IAP use the following statement.
iap_entry (command_param,status_result);
Up to 4 parameters can be passed in the r0, r1, r2 and r3 registers respectively (see the
ARM Thumb Procedure Call Standard SWS ESPC 0002 A-05)
. Additional parameters are
passed on the stack. Up to 4 parameters can be returned in the r0, r1, r2 and r3 registers
respectively. Additional parameters are returned indirectly via memory.