Example Code for IAP LPC1317-64P & ISP vs IAP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Example Code for IAP LPC1317-64P & ISP vs IAP

2,019 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Sat Jan 05 23:35:07 MST 2013
1. Any Example code for IAP.? I have code where I have to store calculated 400 bytes of data on flah & then read it back after later use. Can it be done. Eeprom can be used & have done it but by this I want to learn programming flash with IAP.

2. Also I read that a unanswered question back in forum abt ISP & IAP.
Now keil says


In-System Programming means that the device can be programmed in the circuit by using an utility such as the ULINK USB-JTAG Adapter.

In-Application Programming means that the application itself can re-program the on-chip Flash ROM.
.

Also UM10524 says
In-System programming (ISP) is programming or
reprogramming the on-chip flash memory, using the bootloader software and the
UART serial port. This can be done when the part resides in the end-user board.


Does that mean ULINK interfaced with SDDIO & SWCLK pins, access bootloader software & UART0 of the  LPC then program the IC.

However I debug my code using USART0 with ULINK. It worked fine. No error. As by above statements ULINK will access UART) to program however I am using USARt0 to send code on PC terminal.


Or I misunderstood it.
0 Kudos
Reply
3 Replies

1,333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by aamir ali on Mon Jan 07 02:52:51 MST 2013
Does that mean that:
1. Programming via ULINK with SWD does not access bootloadfer & UART & program it via SW pins. or it access bootloader but not UART.

1. ISP is via bootloader & UART

2. IAP is means to reprogram data on flash.
0 Kudos
Reply

1,333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Sun Jan 06 03:31:59 MST 2013

Quote: Aamir Ali
1. Any Example code for IAP.?



"For those in need of IAP demo code / example code, here's simple code to test the IAP function for NXP ARM Cortex-M MCUs. Tested in LPC11xx, LPC11Cxx, LPC12xx.":

http://www.lpcware.com/content/blog/application-programming-iap-code-example
0 Kudos
Reply

1,333 Views
lpcware
NXP Employee
NXP Employee
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
0 Kudos
Reply