As I did not manage to write to 512 Ko Flash using FL-Flash. I coded routines from the LPC23XX manual that make use of IAP commands. I use the CCLK wired to 12MHz XTAL : CCLK is 48000 kHz. I coded the following sequence to write to a sector :
prepare erase prepare write return compare.
I have 2 questions :
1) Do I Have to Erase the sector before writing. I ask this because it make much time, for example erase a 4K flash takes 400 ms, while writing 256 bytes taks 1.1 ms.
2) As writing disable Flash access, how can I know I my code is executed from flash or RAM ?
Thanks.
For the LPC23xx devices, you can not perform multiple writes to the same page because of ECC. The ECC is the error correction algorithm, which tries to correct single bit errors in flash.
When the page is programmed, ECC code is also written to hidden flash area. If you reprogram the same page without erasing the sector, (by trying to flip some other bits from 1 to 0), the ECC code is not valid anymore and ECC algorithm tries to correct bit errors. This appears as some bits in a page, that were previously programmed to 0, suddenly become 1.
OK. Many thanks for these useful explainations.