The IAP is accessed by calling a Thumb routine at the IAPentry address with the address of a command block in R0 and the address of a status/result block (RAM) in R1. All the IAPxxx words return a 0 result on success. Note also that all interrupts are disabled for the duration of an IAP call, and therefore that ticker interrupts will not be serviced. In particular, the sector erase command may take 400ms, and a write of a 512 byte line may take 1ms.
The LPC210x CPUs have 128kb Flash in 8kb sectors numbered from 0..15. These sectors may be programmed in units of 512 bytes. Sector 15 is the boot sector which cannot be erased or programmed. See the LPC2106 User Manual for more details.
1 equ FullIAP? \ -- n
If this EQUate is set non-zero, additional IAP routines
are compiled, e.g. to get the bootloader version number
and the device part number. The definition here is only
used if it has not been previously defined.
5 cells buffer: IAPcmd \ -- addr ; max 5 cells
Command input buffer for IAP routines.
3 cells buffer: IAPres \ -- addr ; max 3 cells
Result output buffer from IAP routines.
code IAP \ *cmd *res --
The primitive to call the IAP routines. Interrupts are
disabled for the duration of the IAP call.
: IAPprep \ start end -- res
Prepare sectors for erase/write.
: IAPcopy \ Rsrc Fdest len -- res
Copy/program len bytes from Rsrc in RAM to Fdest in Flash.
: IAPerase \ start end -- res
Erase the inclusive range of sectors.
: IAPcheck \ start end -- res
Blank check the inclusive range of sectors.
: IAPcompare \ Rsrc Fdest len -- res
Compare len bytes from Rsrc in RAM to Fdest in Flash.
: IAPbootver \ -- bootver
Return the 16 bit boot code version. The high byte is the
major version and the low byte is the minor version.
: IAPpartno \ -- part#
Return the Philips part number.
If you have problems with the IAP routines, check the bootloader version using the Philips ISP software or by typing
IAPBootVer .dword
which will give something of the form:
0000:xxyy
xx is the major version number and yy is the minor version number. If this number is less than 0000:0134 (hexadecimal) or 1.52 (decimal) you should update the bootloader using ISP software version 2.2.0 or greater. These are available on the MPE CDs and from
|
If you still have problems, use the Philips ISP software to erase the whole of the Flash, and then reinstall an appropriate .HEX file. Remember to convert the latest .IMG file to .HEX.