Content originally posted in LPCWare by michele sponchiado on Fri Jan 15 03:12:22 MST 2016
Hi,this is the sequence which works for me:
[list]
[*]call the Chip_IAP_Init() routine
[*]to program the flash I followed this sequence
[list=1]
[*]loop for every flash sector involved
[*]disable the IRQs!
[*]call the Chip_IAP_PreSectorForReadWrite, check for errors in the return code
[*]call the Chip_IAP_Chip_IAP_EraseSector, check for errors in the return code
[*]loop into the current sector: for every 512 bytes (I think it works also with other bytes size, e.g. 1024, but never tried), I call the Chip_IAP_PreSectorForReadWrite then the Chip_IAP_CopyRamToFlash using a buffer in the internal RAM (I dunno if it works also using external SDRAM), always checking the return code
[*]enable the IRQs!
[*]loop next flash sector
[/list]
[*]if I need to call the Chip_IAP_SetBootFlashBank, but this is really needed if the boot bank has been changed, I call again the Chip_IAP_Init, but I really don't know if it is needed
[/list]