EmbeddedRelated.com
Forums

In Application Programming for LPC2368

Started by "op.shams" October 29, 2007
Dear sir ;

In my project, I want to write some critical data in 512k FLASH
of LPC2368.Here I am using In Application Programming for the same.

I refered code from, C:\Keil\ARM\Flash\LPC_IAP2_512 and I am
facing a problem while I am writing to FLASH like,


int ProgramPage (unsigned long adr, unsigned long sz, long long int
buf[][2]) {

n = GetSecNum(adr); // Get Sector Number

IAP.cmd = 50; // Prepare Sector for Write
IAP.par[0] = n; // Start Sector
IAP.par[1] = n; // End Sector
IAP_Execute (&IAP); // Execute IAP Command
if (IAP.stat) return (1); // Command Failed

IAP.cmd = 51; // Copy RAM to Flash
IAP.par[0] = adr; // Destination Flash Address
IAP.par[1] = (unsigned long)buf;// Source RAM Addres
IAP.par[2] = sz; // Fixed Page Size
IAP.par[3] = CCLK; // CCLK in kHz
IAP_Execute (&IAP); // Execute IAP Command

if (IAP.stat) return (1); // Command Failed

return (0); // Finished without Errors



This code is working fine if I am passing source address
as some array ,which is locally declared in USER RAM.
In my application ,I want to write the data present in
the 8KB USB SRAM memory to FLASH memory.If I am copying the data from
USB memory to USER RAM and then writing this USER RAM data to FLASH
memory,it is success.

But if I am passing the USB address (0x7FD00000) as a parameter to
ProgramPage() ,then it is returning "IAP.status" as "4" , which means
Failure.

In LPC2368 user manual "user.manual.2368.lpc2378.pdf "page number 534
of 614, if I am getting "IAP.status" as "4",it is mentioned
as "Source address is not mapped in the memory map.Count value is
taken in to consideration where applicable ".

I would like to know whether copying data from USB memory to FLASH
memory directly is the correct way or not. If it is correct, How can
I map USB source memory(i.e. the 8kB USB SRAM) as mentioned in the
above paragraph.

sincerely
shamsudheen OP

An Engineer's Guide to the LPC2100 Series