Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Flash problem

Flash problem

2005-02-08 by mobilsiten

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

Re: Flash problem

2005-02-08 by Gus

hold the BL pin then try to connect using philips utility over the 
serial port. If you can't chip is useless.

Gus

--- In lpc2000@yahoogroups.com, "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
Show quoted textHide quoted text
> 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

Re: Flash problem

2005-02-08 by Leighton Rowe

> 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

Re: Flash problem

2005-02-09 by mobilsiten

This is the iap function:
 
void iap (unsigned *cmd,unsigned *rslt,unsigned entry)
{
 asm("mov r15,r2");
}

Its taken from Keils "exercises"

Peter



--- In lpc2000@yahoogroups.com, "Leighton Rowe" <leightonsrowe@y...>
wrote:
Show quoted textHide quoted text
> 
> > 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

Re: Flash problem

2005-02-09 by mobilsiten

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 lpc2000@yahoogroups.com, "Gus" <gus_is_working@y...> wrote:
Show quoted textHide quoted text
> 
> hold the BL pin then try to connect using philips utility over the 
> serial port. If you can't chip is useless.
> 
> Gus
> 
> --- In lpc2000@yahoogroups.com, "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

Re: Flash problem

2005-02-09 by Leighton Rowe

> 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

Re: Flash problem

2005-02-09 by mobilsiten

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:
Show quoted textHide quoted text
> 
> > 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

Re: Flash problem

2005-02-09 by Leighton Rowe

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 
Show quoted textHide quoted text
> > to address location
> > 
> > iap_entry (command, result);   //done

Re: Flash problem

2005-02-09 by mobilsiten

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 lpc2000@yahoogroups.com, "Leighton Rowe" <leightonsrowe@y...>
wrote:
Show quoted textHide quoted text
> 
> 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

Re: Flash problem

2005-02-09 by Leighton Rowe

> 	//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"?

Re: Flash problem

2005-02-09 by mobilsiten

--- In lpc2000@yahoogroups.com, "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" :-)

Re: Flash problem

2005-02-10 by mobilsiten

Ah, finally its solved. 
Thanks for all the help!

--- In lpc2000@yahoogroups.com, "mobilsiten" <petertholander@h...> wrote:
Show quoted textHide quoted text
> 
> --- In lpc2000@yahoogroups.com, "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" :-)

Re: Flash problem

2006-05-08 by guilherme_ferraz

I´ve got the same problem.
If I want to erase the sector, an undef interrupt occurs, if I want to
write to a sector, A SRC_ADDR_ERROR occurs.

Could you tell me what did you do?
Thanks.


--- In lpc2000@yahoogroups.com, "mobilsiten" <petertholander@...> wrote:
>
> 
> 
> Ah, finally its solved. 
> Thanks for all the help!
> 
> --- In lpc2000@yahoogroups.com, "mobilsiten" <petertholander@h...>
wrote:
Show quoted textHide quoted text
> > 
> > --- In lpc2000@yahoogroups.com, "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" :-)
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.