>
> I forgot to mention that IAP commands may take a while to complete.
> From the below code example (IAR), I think you'll have to
> continually call the IAP and check the the status flag for
> completion.
>
>
> //for (;;)
> //{
> // iap_entry(cmd, status);
> // ret = status[0];
> // if (ret != STATUS_BUSY)
> // {
> // return ret; //or anything else that exits
> // }
> //}
>
>
>
>
>
>
>
>
> --- In lpc2000@yahoogroups.com, "mobilsiten" <petertholander@h...>
> wrote:
> >
> > Now I have changed the code to this:
> >
> > IAP iap_entry;
> >
> > iap_entry = (IAP) IAP_LOCATION;
> >
> > //Prepare sector
> > command[0] = 50; // Command
> > command[1] = 7; // Start sector
> > command[2] = 7; // Stop sector
> > iap_entry(command,result);
> > /*
> > //Erase sector
> > command[0] = 52; // Command
> > command[1] = 7; // Start sector
> > command[2] = 7; // Stop sector
> > command[3] = 60000; // System clock frekquency in (CCLK)
> KHz
> > iap_entry(command,result);
> >
> > //Prepare sector
> > command[0] = 50; // Command
> > command[1] = 7; // Start sector
> > command[2] = 7; // Stop sector
> > iap_entry(command,result);
> > */
> >
> > //Write
> > command[0] = 51; // Command
> > command[1] = 0x0000E000; // Start adress
> > command[2] = source; // Data
> > command[3] = 512; // Size of data 512
> | 1024 | 4096 | 8192
> > command[4] = 60000; // System clock frekquency
> in (CCLK) KHz
> > iap_entry(command,result);
> >
> >
> > But it still dosent work. If i try to erase it seems like I mess ut
> > the interrupt vector and if I try "copy to ram" I get
> SRC_ADDR_NOT_MAPPED.
> >
> >
> > --- In lpc2000@yahoogroups.com, "Leighton Rowe"
> <leightonsrowe@y...>
> > wrote:
> > >
> > > > This is the iap function:
> > > >
> > > > void iap (unsigned *cmd,unsigned *rslt,unsigned entry)
> > > > {
> > > > asm("mov r15,r2");
> > > > }
> > >
> > > You're overwriting the PC (program counter) which is one of the
> > > scariest things u can do. Usually this results in prefetch
> aborts.
> > > You can to branch to the IAP bootloader address location by
> using a
> > > function pointer.
> > >
> > >
> > > The code below is some example code taken from the User Manual
> for
> > > the lpc you are using.
> > >
> > > #define IAP_LOCATION 0x7ffffff1 //address of IAP BL
> > >
> > > unsigned long command[5];
> > > unsigned long result[2];
> > >
> > > typedef void (*IAP)(unsigned int [],unsigned int[]); //function
> ptr
> > >
> > > IAP iap_entry;
> > > iap_entry=(IAP) IAP_LOCATION; // function pointer declared and
> set
> > > to address location
> > >
> > > iap_entry (command, result); //done