Content originally posted in LPCWare by Rob65 on Sun Jan 06 01:49:53 MST 2013
Some remarks and Questions:
[LIST]
[*]It is just a Flash, not a Flash ROM (RO means Read Only whereas a flash can be rewritten).
[*]There is no USART, the LPC has one or more UARTs
[*]uLink is a JTAG/SWD debugger and does not use UART0.
JTAG is the 'old' standard for debugging, SWD the new one. SWD needs less pins than JTAG to be able to debug, possibly releasing more pins to user functions (depending on the device).
There is a console channel for printing to using printf when using semi-hosting but this has nothing to do with actual UART hardware. You can easily use all uarts in your application and still printf to the semi hosting console - can be quite handy when debugging stuff
[/LIST]
Then further with IAP / ISP:
[LIST]
[*]ISP is In System Programming and this uses a UART to download the code to the flash. For this you need a minimal set of 3 I/O pins (RX/TX and an ISP enable pin).
[*]Connecting to a JTAG debugger link uLink is not called ISP although some LPC variants have dedicated JTAG pins so you could use these to program your device while it is in the system.
[*]IAP is the name of the interface that NXP created that is used to program the Flash memory.
[/LIST]
Your subject mentions "ISP versus IAP" but these things are different: ISP is used to program your chip (with a program) whereas IAP is just a means to write some data to some place in the Flash.
Since the program executes directly from flash it is not possible to rewrite flash blocks that your program is using, the USB_bootloader program that can be found in the RDB1768 examples (installed with the LPCXpresso IDE) contains a nice example on how you can program the Flash from within an application.
But if you just want to use the flash as an EEPROM replacement, read the IAP section in the user manual - there you will find all the details you need to start flash programming. The flash programming part of the USB bootloader contains an implementation of this.
Please note that the flash consists of a number of blocks with different sizes and you can only erase a flash block by block. In an EEPROM you can just rewrite a single byte with data but in a flash you need to erase the old data first before being able to rewrite new data.
If you erase the flash block your program is in, you will erase your program and it stops working. You have to change the .ld (linker descriptor) file in order to leave the blocks you want to use in your application alone. Actually ... you could create a separate section for the data in your flash block but that's not something I would start with. Just using a simple uint8_t * to address the data in your flash is the easiest thing to start with.
Please bear in mind that Flash has a limited number of erase/write cycles. If I remeber well something like 100,000 times and if your flash wears out you cannot use those blocks anymore. EEPROM has more write cycles and is better for storing user changeable settings. The 1317 has an onboard 4 kB EEPROM that can be programmed using the same interface as programming the Flash.
Please have a look at chapter 21 "Flash/EEPROM programming firmware" in the user manual.
Sorry, I don't own an lpc1317 or comparable target so I am not able to provide you with an out of the box working example
Rob