I want o store a bit in Non-VOlatile Memory (FLash of LPC2103) when my
program is running?
Steps to do the same is appreciated.
Any Sample Codes??
How to Write into LPC2103 Flash during Program Execution
Started by ●March 5, 2008
Reply by ●March 5, 20082008-03-05
--- In l..., "ramakrishnan_76"
wrote:
>
> I want o store a bit in Non-VOlatile Memory (FLash of LPC2103) when my
> program is running?
>
> Steps to do the same is appreciated.
>
> Any Sample Codes??
>
Hi
All details about doing this are included in the LPC2103 users' manual
- see the section about boot loader.
Here's a short extract from the uTasker project of performing the write:
IAP iap_entry = IAP_LOCATION;
unsigned long command[5];
// command buffer to be passed to IAP routine
unsigned long result[3];
// result buffer for use by the IAP routine
unsigned long ulSector = fnGetFlashSector((unsigned
long)ptrFlashAddress);
command[0] = FLASH_PREPARE_SECTOR_TO_WRITE;
// prepare the sector for the command
command[1] = ulSector;
command[2] = ulSector;
uDisable_Interrupt();
// protect FLASH routine from interrupts
iap_entry(command, result);
// call the IAP routine
uEnable_Interrupt();
if (result[0] != CMD_SUCCESS) {
return 1;
// sector invalid or busy
}
command[0] = FLASH_COPY_RAM_TO_FLASH;
command[1] = (unsigned long)ptrFlashAddress;
// flash destination start address (256 byte boundard)
command[2] = (unsigned long)ucFlashRow;
// source ram address is always the ROW backup buffer (word aligned)
command[3] = FLASH_ROW_SIZE;
// allowed: 256 | 512 | 1024 | 4096 | 8192 - we use always the row size
command[4] = (MASTER_CLOCK/1000);
// system clock frequency (CCLK) in kHz
uDisable_Interrupt();
// protect FLASH routine from interrupts
iap_entry(command, result);
// call the IAP routine
uEnable_Interrupt();
if (result[0] != CMD_SUCCESS) {
return 1;
// write error
}
The defines can be found in the manual - fnGetFlashSector() is not
needed if you only want to write to a fixed one.
The IAP location tends to be defined like this:
typedef void (*IAP)(unsigned long [], unsigned long []);
#define IAP_LOCATION (IAP)0x7ffffff1
// Thumb mode execution address of Incircuit Application
Programming routine
The full code is open source and available in the uTasker project at
www.uTasker.com. There is an overview of using the IAP and the details
of the FLASH in the LPC at:
http://www.utasker.com/forum/index.php?topic6.0
Note too that there needs to be some RAM reserved at the top of the
stack for the IAP routine to use (it can otherwise destroy memory).
The uTasker project supports the LPC2101/2/3 as well as the larger
types with Ethernet.
Regards
Mark
wrote:
>
> I want o store a bit in Non-VOlatile Memory (FLash of LPC2103) when my
> program is running?
>
> Steps to do the same is appreciated.
>
> Any Sample Codes??
>
Hi
All details about doing this are included in the LPC2103 users' manual
- see the section about boot loader.
Here's a short extract from the uTasker project of performing the write:
IAP iap_entry = IAP_LOCATION;
unsigned long command[5];
// command buffer to be passed to IAP routine
unsigned long result[3];
// result buffer for use by the IAP routine
unsigned long ulSector = fnGetFlashSector((unsigned
long)ptrFlashAddress);
command[0] = FLASH_PREPARE_SECTOR_TO_WRITE;
// prepare the sector for the command
command[1] = ulSector;
command[2] = ulSector;
uDisable_Interrupt();
// protect FLASH routine from interrupts
iap_entry(command, result);
// call the IAP routine
uEnable_Interrupt();
if (result[0] != CMD_SUCCESS) {
return 1;
// sector invalid or busy
}
command[0] = FLASH_COPY_RAM_TO_FLASH;
command[1] = (unsigned long)ptrFlashAddress;
// flash destination start address (256 byte boundard)
command[2] = (unsigned long)ucFlashRow;
// source ram address is always the ROW backup buffer (word aligned)
command[3] = FLASH_ROW_SIZE;
// allowed: 256 | 512 | 1024 | 4096 | 8192 - we use always the row size
command[4] = (MASTER_CLOCK/1000);
// system clock frequency (CCLK) in kHz
uDisable_Interrupt();
// protect FLASH routine from interrupts
iap_entry(command, result);
// call the IAP routine
uEnable_Interrupt();
if (result[0] != CMD_SUCCESS) {
return 1;
// write error
}
The defines can be found in the manual - fnGetFlashSector() is not
needed if you only want to write to a fixed one.
The IAP location tends to be defined like this:
typedef void (*IAP)(unsigned long [], unsigned long []);
#define IAP_LOCATION (IAP)0x7ffffff1
// Thumb mode execution address of Incircuit Application
Programming routine
The full code is open source and available in the uTasker project at
www.uTasker.com. There is an overview of using the IAP and the details
of the FLASH in the LPC at:
http://www.utasker.com/forum/index.php?topic6.0
Note too that there needs to be some RAM reserved at the top of the
stack for the IAP routine to use (it can otherwise destroy memory).
The uTasker project supports the LPC2101/2/3 as well as the larger
types with Ethernet.
Regards
Mark
Reply by ●March 6, 20082008-03-06
Hello,
I read;
"The full code is open source and available in the uTasker project at
www.uTasker.com. There is an overview of using the IAP and the details
of the FLASH in the LPC at:"
But I cannot find any open source code concerning the bootloader on
your website. Maybe a direct link ?
Thanks in advance .
Yann.
I read;
"The full code is open source and available in the uTasker project at
www.uTasker.com. There is an overview of using the IAP and the details
of the FLASH in the LPC at:"
But I cannot find any open source code concerning the bootloader on
your website. Maybe a direct link ?
Thanks in advance .
Yann.
Reply by ●March 6, 20082008-03-06
Hi friend,
you can take a look at my old post namely:
R: [lpc2000] Introduction to Lpc2000 needed
dated 06 Feb 2008, inside there is a in deep note how to use Flash
as EEPROM for LPC2106, then I think this can be also used for
LPC2103.
Cheers
Fabio Filippa
--- In l..., "ramakrishnan_76"
wrote:
>
> I want o store a bit in Non-VOlatile Memory (FLash of LPC2103)
when my
> program is running?
>
> Steps to do the same is appreciated.
>
> Any Sample Codes??
>
you can take a look at my old post namely:
R: [lpc2000] Introduction to Lpc2000 needed
dated 06 Feb 2008, inside there is a in deep note how to use Flash
as EEPROM for LPC2106, then I think this can be also used for
LPC2103.
Cheers
Fabio Filippa
--- In l..., "ramakrishnan_76"
wrote:
>
> I want o store a bit in Non-VOlatile Memory (FLash of LPC2103)
when my
> program is running?
>
> Steps to do the same is appreciated.
>
> Any Sample Codes??
>
Reply by ●March 6, 20082008-03-06
--- In l..., "nourson54" wrote:
>
> Hello,
>
> I read;
>
> "The full code is open source and available in the uTasker project at
> www.uTasker.com. There is an overview of using the IAP and the details
> of the FLASH in the LPC at:"
> But I cannot find any open source code concerning the bootloader on
> your website. Maybe a direct link ?
>
> Thanks in advance .
>
> Yann.
>
Hi
The only requirement to receiving complete code is a simple
registration - this is not used for any purpose other than helping aid
support - see the licensing terms here:
http://www.utasker.com/Licensing/License.html
The on-line application form is here:
http://www.utasker.com/Licensing/request.html
Regards
Mark
>
> Hello,
>
> I read;
>
> "The full code is open source and available in the uTasker project at
> www.uTasker.com. There is an overview of using the IAP and the details
> of the FLASH in the LPC at:"
> But I cannot find any open source code concerning the bootloader on
> your website. Maybe a direct link ?
>
> Thanks in advance .
>
> Yann.
>
Hi
The only requirement to receiving complete code is a simple
registration - this is not used for any purpose other than helping aid
support - see the licensing terms here:
http://www.utasker.com/Licensing/License.html
The on-line application form is here:
http://www.utasker.com/Licensing/request.html
Regards
Mark