--- In , "mobilsiten" <petertholander@h...> wrote: >
> --- In , "Leighton Rowe" <leightonsrowe@y...>
> wrote:
> >
> > > //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
> >
> > It looks like everything but the write command is ok. Just for
> > clarity, what you're using for the variable
"source"?
>
> source is a pointer to a char array with the data i want to write to
> the flash in this case the famous "Hello world" :-)
--- In , "Leighton Rowe" <leightonsrowe@y...>
wrote: >
> > //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
>
> It looks like everything but the write command is ok. Just for
> clarity, what you're using for the variable "source"?
source is a pointer to a char array with the data i want to write to
the flash in this case the famous "Hello world" :-)
Reply by Leighton Rowe●February 9, 20052005-02-09
> //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
It looks like everything but the write command is ok. Just for
clarity, what you're using for the variable "source"?
Reply by mobilsiten●February 9, 20052005-02-09
Sorry, still dosent work I directly get the error code SRC_ADDR_NOT_MAPPED
I dont dissable the interrupts (because I have not manage to solve
this eighter...)
But I dont think there can be any interrupts because this is the only
code in the application,,,as long as the cpu dosent create any own
interrupts...
--- In , "Leighton Rowe" <leightonsrowe@y...>
wrote: >
> 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 , "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 , "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
Reply by Leighton Rowe●February 9, 20052005-02-09
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 , "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 , "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
//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 , "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
Reply by Leighton Rowe●February 9, 20052005-02-09
> 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
Reply by mobilsiten●February 9, 20052005-02-09
Ok, thanks this solved the problem. Still I would like to know how
this could totally messup the CPU....
Can someone tell me??
Peter
--- In , "Gus" <gus_is_working@y...> wrote: >
> hold the BL pin then try to connect using philips utility over the
> serial port. If you can't chip is useless.
>
> Gus
>
> --- In , "mobilsiten" <petertholander@h...>
> wrote:
> >
> > Hi!
> >
> > I'm pretty new on this and I think i screwed it up really good
> directly
> >
> > I made this code and tried it:
> >
> > void writeToFlash()
> > {
> > command[0] = 54;
> > iap(command,result,0x7FFFFFF0);
> >
> > command[0] = 55;
> > iap(command,result,0x7FFFFFF0);
> >
> > //Prepare sector
> > command[0] = 50; // Command
> > command[1] = 8; // Start sector
> > command[2] = 8; // Stop sector
> > iap(command,result,0x7FFFFFF0);
> >
> > //Erase sector
> > command[0] = 52; // Command
> > command[1] = 8; // Start sector
> > command[2] = 8; // Stop sector
> > iap(command,result,0x7FFFFFF0);
> >
> > }
> >
> > Offcourse it didnt work because I forgot to set the CCLK in the
> erase
> > part.
> > But this was not all, after this I cant access the CPU again. I get
> > this error message: "Memory Missmatch Adress: 0x00000000 Value =
> 0x00
> > Expected = 0x18".
> > Have I screwed up the CPU totally or is there anything I can do to
> > make it work again?
> >
> > Please can someone help me?
> >
> > Thanks
Peter
--- In , "Leighton Rowe" <leightonsrowe@y...>
wrote: >
> > void writeToFlash()
> > {
> > command[0] = 54;
> > iap(command,result,0x7FFFFFF0);
> >
> > command[0] = 55;
> > iap(command,result,0x7FFFFFF0);
> I'd really like to see how u defined your iap function pointer.
>
> Regardless, ensure that the IAP function pointer switches to thumb
> mode and takes 'only' 2 arguments (Command & Result). Note
that
> function pointer must go to address 0x7ffffff1 (not 0x7ffffff0).
>
> Look closely at the "IAP Command" section in "Flash Memory
System &
> Programming" in your User Manual.
>
> Leighton
Reply by mobilsiten●February 8, 20052005-02-08
Hi!
I'm pretty new on this and I think i screwed it up really good directly
Offcourse it didnt work because I forgot to set the CCLK in the erase
part.
But this was not all, after this I cant access the CPU again. I get
this error message: "Memory Missmatch Adress: 0x00000000 Value = 0x00
Expected = 0x18".
Have I screwed up the CPU totally or is there anything I can do to
make it work again?