9 years, 3 months ago.

IAP not working?

Hello to all. I don't know how to do with this big problem. My problem is that Code is compiled correctly but it doesn't work at all with soft Keil. I'm working on it for more than 1 month but I couldn't understand what my problem is? :( Can somebody help me with it. Thanks and thank you so much. :)

my code is this>>>

  1. include <lpc17xx.h>
  2. include <absacc.h>

void IAP_Write(void); unsigned char a[5] at(0x10000400);

unsigned int command[5]; unsigned int result[5]; typedef void (*IAP)(unsigned int [],unsigned int[]); IAP iap_entry=(IAP) 0x1FFF1FF1;

int main(void) { unsigned char i=0; for(i=0;i<5;i++) a[i]=i; IAP_Write(); } void IAP_Write(void) { command[0]=50; command[1]=8; Start sector number is 8 command[2]=8; Finish sector number is 8 iap_entry(command,result);

command[0]=51; command[1]=0x00008100; Addrees of Flash command[2]=0x10000400; Addrees of Sram command[3]=256; How many bytes want to transfer command[4]=12000; Frequency in khz iap_entry(command,result); }

1 Answer

9 years, 3 months ago.

Hi,

I noticed one thing that you may need to set the "CPU Clock Frequency" appropriately.
So it may need to be "96000" isn case of default setting of mbed LPC1768 but you may need to adjust it if you modified the PLL settings.

I tried testing your code with some tweaks. This works fine :)
Please find the code from following link.

Import programtest_iap_20150205

small test code for IAP

Information

2015-Feb-08
The sample code has been modified to add some commands to demonstrate "blank check", "erase" and "compare". And also, I added a check list below. This may help if the IAP doesn't work on your environment.

Here is a check list if you cannot get the flash which doesn’t have data you wrote:

  • IAP routines calls
    • Check return code of IAP routine calls. It should be zero for “prepare”, “erase” and “copy_RAM_to_flash”.
    • Check the parameters for all IAP calls. The sector numbers and address should be consistent.

Even of the return code is 0 but still having problem, further checking may be required.
Please continue checking with following steps.

  • Write and erase command parameter
    • Check the CPU clock setting. If it is too small, the IAP cannot complete the commands (for instance, mbed-LPC1768 needs "96000" as clock frequency parameter).
  • Flash conditions
    • Make sure the flash is ready for writing. The address area of the flash must be erased before writing. If the flash overwritten without erasing, the data will be corrupted.
    • When you start the data into new sector, perform blank check and erasing.
  • Preparing and verifying data
    • Use IAP’s “compare” command to verify the data written into the flash.
    • Or, you can read the flash by using physical address as pointer to the flash area.

More comprehensive sample is available here.

Import programIAP_internal_flash_write

Sample code for how to erase/write LPC1768, LPC11U24, LPC1114, LPC812 and LPC824 internal flash memory. This program uses IAP call of MCU's ROM routines. The IAP library also supports read/write of EEPROM in LPC11U24.