LPC2106: Flash memory read (IAP flash read function ?)

Hi all,

this is my first post, don’t kick me please :smiley: , I’m working with a LPC2106 microcontroller and using the IAR Embedded Workbench KickStart board. It work well, now I’ve found how to write a data to Flash by using the IAP functions. But really I can’t found similar command to use in order to retrieve back the data previously written into the Flash locations.

I need to know how I can read Flash (in C language) because I’ve to use some Flash ROM like a EEPROM to store some configuration data which I’ve to update sometime during the program running and retrieve at the startup before take the main routine execution.

My idea is keep data storage into the last block before the boot loader block then the 14 block number.

If someone can help me… thanks in advance

Fabio

Hi,

Look this application notes:

http://www.semiconductors.philips.com/a … 0256_2.pdf

Also get the file EE_demo_1_1.zip on lpc2000 yahoo groups

Hi, tnx for reply.

Well I know this app-note and I’ve already read this paper (but thanks very much for the hint related the example on the Yahoo grpups), now

I’m using the code to write into the Flash which is into the IAR Embedded Workbench src folder, now I’ve two question:

  1. how I can check into the Flash memory if some value was effectively writed, actually I’m using the J-Tag debugger.

  2. after some other reading I think is possible read the Flash memory by inspect the return value from a BlanckCheck operation (may be a idea?)

Some hints?

Thanks again

Fabio

Ok,

finally I’ve figure out how to do all the stuff, reading is more simple just a pointer access to the flash address…

For example, if we have to read a 16 bit value (lobyte and hybyte) from Flash we can write (LPC2106 IAR System Embedded Workbench ver. 4.31A):

#define ADDR_ZEROSET_HYBYTE 0x1C000;  // FLASH: lobyte (sector 14)
#define ADDR_ZEROSET_LOBYTE 0x1C004;  // FLASH: hybyte (sector 14)

......

__no_init int lobyte;                           // lobyte storage variable
__no_init int hybyte;                          // hybyte storage variable
__no_init unsigned long loaddr;          // lobyte address location (Flash)
__no_init unsigned long hyaddr;         // hybyte address location (Flash)

......

loaddr = (unsigned long)ADDR_ZEROSET_LOBYTE;
hyaddr = (unsigned long)ADDR_ZEROSET_HYBYTE;
lobyte = 0;
lobyte = *((int*)loaddr) & 0xFF;   // Read the lobyte 
hybyte = 0;
hybyte = *((int*)hyaddr) & 0xFF; // Read the hybyte
Value = hybyte * 256 + lobyte;   // Make the final value from lo and hy byte

if someone find this way not good please feel free to signal it to me thanks.

Also memory can be viewed by using the View Memory option which is into the Workbench IDE when the debug is stopped.

http://www.Photo-Host.org/thumb/034993view.png

In order to check if the Flash writing was succeed you can also use the LPC2000 Flash utility (I’ve test it on the release v2.0.1) which came from Philips, then simply select the Buffer → Flash Buffer Operations:

http://www.Photo-Host.org/thumb/375446fig1.png

then go to the bottom of the window into the Address Range section and write the Flash start and Flash end address at this point you’re ready to download the Flash selected memory address, simply press the Download Flash button (in the example below I like to read the first 0x100 location from the start of the block 14).

http://www.Photo-Host.org/thumb/531192fig2.png

Of course I know this may be obvious stuff, but I’m a newbie with this uP and related develop environment this is the reason because I’m writing all in deep format, may be useful also for other noob peple :wink: .

I’m sorry if this may be boring someone.

Cheer

Fabio