Below is the code I use to write and erase flash areas. Below is setup of IAP call then usage .This should get you started .
Good luck
/*------------------------------------------------------------------------
Module: C:\Tools\Code\PForth\csrc\LPC21IAP.c
Author: Tom
Project:
State:
Creation Date:
Description: In-Application (IAP) programming is the
performing of erase and write operations on
the
on-chip Flash memory as directed by the
end-user application code. The Flash boot
loader provides the interface for programming
the Flash memory. For detailed information
on the In-Application Programming please refer
to the Flash Memory System and
Programming chapter in the ARM LPC device User
Manual. In this application note, code
samples are provided in C and assembly, which
show how IAP may be used. The IAP
routine resides at 0x7FFFFFF0 and is Thumb
code.
------------------------------------------------------------------------*/
// -mthumb-interwork must set compiler option
#define rm_init_entry 0x7fffff90
#define rm_undef_handler 0x7fffffa0
#define rm_prefetchabort_handler 0x7fffffb0
#define rm_dataabort_handler 0x7fffffc0
#define rm_irqhandler 0x7fffffd0
#define rm_irqhandler2 0x7fffffe0
#define iap_start 0x7ffffff1 // for thumb mode set bit 0 to 1
#define iap_PrepSector 50
#define iap_CopyRamFlash 51
#define iap_erase 52
#define iap_blankCheck 53
#define iap_PartId 54
#define iap_Compare 56
#define iap_ReinvokeISP 57
typedef void (*IAP)(unsigned int ,unsigned int);
IAP iap_entry;
/ ***** EXAMPLE OF USAGE ******
case ID_IAP:
while(uart1TxEmpty()==0); // wait to clear all data in s
VICIntEnClr=0xFFFFFFFF;
VICSoftIntClr=0xFFFFFFFF;
PLLCON=0; // disable pll
PLLFEED=0xAA;
PLLFEED=0x55;
VPBDIV=0; // default back to 1/4 speed of system
iap_entry=(IAP) iap_start;
Scratch=M_POP;
iap_entry((unsigned int *)TOS,(unsigned int *)Scratch);
M_DROP;
initIO();
endcase;