EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

External Flash as EEPROM

Started by wickedmonster2002 June 29, 2006
Hello,

I am using an LPC2210 on Phytec Board, and (I assume) you all know
that the LPC2210 does not have an internal flash, nor does it have
IAP. So, programming is purely done through external flash and
external ram. (it does have 16 kb internal ram, but i dont use it).

My question is, is it possible to use some memory locations or sectors
of external flash as eeprom, or a place to store parameters
essentially given the microcontroller i m using?

I am using 2 16-bit 2M external flash modules interfaced at 32-bits
(meaning total of 2M at 32 bits), and the part no. is AM29x800BT.

These chips are made by Spansion ( a sister company of AMD:
www.spansion.com) and they say they have provided a low level DMS or
Data Management Software for these particular flash modules, but for
me, in my limited experience is too complex to use.

Does anybody have a better idea to store parameters in external flash
without going through the third party way?

Thanks a bunch!

MMK...

An Engineer's Guide to the LPC2100 Series

Hello!

You could connect a normal SD-Card to the SPI-Bus of the device. This is
really cheap and you can store high amounts of data in the card. You can
also use a simple filesystem (like FAT) with the card. Like this, you
can easily read and/or write to the card with a PC.

Regards, mcs

wickedmonster2002 wrote:
>
> Hello,
>
> I am using an LPC2210 on Phytec Board, and (I assume) you all know
> that the LPC2210 does not have an internal flash, nor does it have
> IAP. So, programming is purely done through external flash and
> external ram. (it does have 16 kb internal ram, but i dont use it).
>
> My question is, is it possible to use some memory locations or sectors
> of external flash as eeprom, or a place to store parameters
> essentially given the microcontroller i m using?
>
> I am using 2 16-bit 2M external flash modules interfaced at 32-bits
> (meaning total of 2M at 32 bits), and the part no. is AM29x800BT.
>
> These chips are made by Spansion ( a sister company of AMD:
> www.spansion.com) and they say they have provided a low level DMS or
> Data Management Software for these particular flash modules, but for
> me, in my limited experience is too complex to use.
>
> Does anybody have a better idea to store parameters in external flash
> without going through the third party way?
>
> Thanks a bunch!
>
> MMK...

wickedmonster2002 wrote:

> Hello,
>
> I am using an LPC2210 on Phytec Board, and (I assume) you all know
> that the LPC2210 does not have an internal flash, nor does it have
> IAP. So, programming is purely done through external flash and
> external ram. (it does have 16 kb internal ram, but i dont use it).
>
> My question is, is it possible to use some memory locations or sectors
> of external flash as eeprom, or a place to store parameters
> essentially given the microcontroller i m using?
>
> I am using 2 16-bit 2M external flash modules interfaced at 32-bits
> (meaning total of 2M at 32 bits), and the part no. is AM29x800BT.
>
Yes, but the AM29F800 devices are not such that you can run the Flash
programming code in the same device. Once you place the device into
Write or Erase mode, it will "disappear" while the operation commences.
When the operation finishes, the Flash Array will become visable
(usable) again.

You could either run your Flash programming code in one device to
program the other. Or, you could simply locate or move code into RAM
and run it from there.

There is appnote code on using Flash as a EEPROM, but it is nothing
fancy, just simple write / erase / read routines unique to the IAP of
Philips. You could easily roll your own code. You do have some 8K
sectors in that device, that would be the smallest EEPROM size
feasible. If you want to change a byte, you would have to copy that
data into RAM, change it, Erase the 8K sector, and Write the 8k back
into the Flash.

It is clumsy, but do-able.

The other suggestion that someone made about using an SD card is
problematic. You would probably use as much RAM doing an SD card
storage as you would the 8K Flash sector... IMHO, the best solution is
to put a MicroWire Serial EEPROM on the card, or use an SPI EEPROM, look
at:
http://www.digikey.com/scripts/DkSearch/dksus.dll?Detail?Ref!70&Row07570&Site=US
TomW

> These chips are made by Spansion ( a sister company of AMD:
> www.spansion. com) and they say they have provided a low level DMS or
> Data Management Software for these particular flash modules, but for
> me, in my limited experience is too complex to use.
>
> Does anybody have a better idea to store parameters in external flash
> without going through the third party way?
>
> Thanks a bunch!
>
> MMK...
>
>

--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------

Tom > Philips. You could easily roll your own code. You do have some 8K
> sectors in that device, that would be the smallest EEPROM size
> feasible. If you want to change a byte, you would have to copy that
> data into RAM, change it, Erase the 8K sector, and Write the 8k back
> into the Flash.
>
> It is clumsy, but do-able.

I think with some management code and splitting up the 8K page into
several small EEPROM-sectors it is not so painfull.

E.g. 8K => 16 sectors with 512Bytes. The first byte of a sector gives
info if it is free or not.
Init:
1) Erase Page
2) Write 0xfe to first byte first sector => sector in use.

Read:
1) Search all sectors for 0xfe in the first byte.
2) read from the following bytes.

Write:
1) Search all sectors for 0xfe in the first byte.
2) Check if writing on the existing data will work.
(Note: If the you have an "A", it may be overwritten by an "@", since
clearing bits is always possible).
3) If not, copy old+new contents into the next free sector (1st byte 0xff).
4)Change the 1st byte of the old sector to 0xfc, change the 1st
byte of the new sector to 0xfe.
(Maybe otherway round to be fail-safe)
5) If no spare sector, copy to ram, erase page, go to 3

Esp. 4) is dangerous, which could be handled savely if a second backup
page is used.

But for all this: You have to run the code from RAM.

BTW: If powerfail is no problem and the NVM has to be written very
often, I'd use the internal RAM and copy it back from time to time
into flash.

The question is, does this extra work pays of a small EEPROM.
> to put a MicroWire Serial EEPROM on the card, or use an SPI EEPROM, look

--
42Bastian
Quoting Tom Walsh :
> The other suggestion that someone made about using an SD card is
> problematic. You would probably use as much RAM doing an SD card
> storage as you would the 8K Flash sector... IMHO, the best solution is
> to put a MicroWire Serial EEPROM on the card, or use an SPI EEPROM,

Or, especially if you change parameters frequently, look at FRAM. It's faster
by quite a bit and supports many more write cycles.

Robert

I am considering the SPI EEPROM option very seriously now, because I
just got a software driver from AMD and it just doesnt't look
promising. The amount of work is insane, not to mention the cost.

Just out of curiousity, how do you place code to run in RAM while you
are running in Flash? I am using the .ini files provided by Phytec to
choose between running from RAM or running from Flash, depending
whether i want to debug the program or not. So i purely have a user's
view of how to run things in memory, rather than a hardcore hardware
perspective.
--- In l..., Tom Walsh wrote:
>
> wickedmonster2002 wrote:
>
> > Hello,
> >
> > I am using an LPC2210 on Phytec Board, and (I assume) you all know
> > that the LPC2210 does not have an internal flash, nor does it have
> > IAP. So, programming is purely done through external flash and
> > external ram. (it does have 16 kb internal ram, but i dont use it).
> >
> > My question is, is it possible to use some memory locations or sectors
> > of external flash as eeprom, or a place to store parameters
> > essentially given the microcontroller i m using?
> >
> > I am using 2 16-bit 2M external flash modules interfaced at 32-bits
> > (meaning total of 2M at 32 bits), and the part no. is AM29x800BT.
> >
> Yes, but the AM29F800 devices are not such that you can run the Flash
> programming code in the same device. Once you place the device into
> Write or Erase mode, it will "disappear" while the operation
commences.
> When the operation finishes, the Flash Array will become visable
> (usable) again.
>
> You could either run your Flash programming code in one device to
> program the other. Or, you could simply locate or move code into RAM
> and run it from there.
>
> There is appnote code on using Flash as a EEPROM, but it is nothing
> fancy, just simple write / erase / read routines unique to the IAP of
> Philips. You could easily roll your own code. You do have some 8K
> sectors in that device, that would be the smallest EEPROM size
> feasible. If you want to change a byte, you would have to copy that
> data into RAM, change it, Erase the 8K sector, and Write the 8k back
> into the Flash.
>
> It is clumsy, but do-able.
>
> The other suggestion that someone made about using an SD card is
> problematic. You would probably use as much RAM doing an SD card
> storage as you would the 8K Flash sector... IMHO, the best solution is
> to put a MicroWire Serial EEPROM on the card, or use an SPI EEPROM,
look
> at:
>
http://www.digikey.com/scripts/DkSearch/dksus.dll?Detail?Ref!70&Row07570&Site=US
> TomW
>
> > These chips are made by Spansion ( a sister company of AMD:
> > www.spansion. com) and they say they have provided a low level DMS or
> > Data Management Software for these particular flash modules, but for
> > me, in my limited experience is too complex to use.
> >
> > Does anybody have a better idea to store parameters in external flash
> > without going through the third party way?
> >
> > Thanks a bunch!
> >
> > MMK...
> >
> >
>
> --
> Tom Walsh - WN3L - Embedded Systems Consultant
> http://openhardware.net, http://cyberiansoftware.com
> "Windows? No thanks, I have work to do..."
> ----------------
>
If your space requirement for parameters is small, say, less than
8KByte, consider a I2C EEPROM. The RAM requirement for buffering is
the same as the number of bytes in one page, typically 128 bytes.
I'm using AT24C64A (8 Kbyte, 32 byte pages) for parameter store. With
decent capacitors in your power supply and early warning detection,
you could even have time to save your parametes when the power goes
out...
Lars
--- In l..., "wickedmonster2002" wrote:
>
> I am considering the SPI EEPROM option very seriously now, because I
> just got a software driver from AMD and it just doesnt't look
> promising. The amount of work is insane, not to mention the cost.
>
> Just out of curiousity, how do you place code to run in RAM while
you
> are running in Flash? I am using the .ini files provided by Phytec
to
> choose between running from RAM or running from Flash, depending
> whether i want to debug the program or not. So i purely have a
user's
> view of how to run things in memory, rather than a hardcore hardware
> perspective.
> --- In l..., Tom Walsh wrote:
> >
> > wickedmonster2002 wrote:
> >
> > > Hello,
> > >
> > > I am using an LPC2210 on Phytec Board, and (I assume) you all
know
> > > that the LPC2210 does not have an internal flash, nor does it
have
> > > IAP. So, programming is purely done through external flash and
> > > external ram. (it does have 16 kb internal ram, but i dont use
it).
> > >
> > > My question is, is it possible to use some memory locations or
sectors
> > > of external flash as eeprom, or a place to store parameters
> > > essentially given the microcontroller i m using?
> > >
> > > I am using 2 16-bit 2M external flash modules interfaced at 32-
bits
> > > (meaning total of 2M at 32 bits), and the part no. is
AM29x800BT.
> > >
> > Yes, but the AM29F800 devices are not such that you can run the
Flash
> > programming code in the same device. Once you place the device
into
> > Write or Erase mode, it will "disappear" while the operation
> commences.
> > When the operation finishes, the Flash Array will become visable
> > (usable) again.
> >
> > You could either run your Flash programming code in one device to
> > program the other. Or, you could simply locate or move code into
RAM
> > and run it from there.
> >
> > There is appnote code on using Flash as a EEPROM, but it is
nothing
> > fancy, just simple write / erase / read routines unique to the
IAP of
> > Philips. You could easily roll your own code. You do have some
8K
> > sectors in that device, that would be the smallest EEPROM size
> > feasible. If you want to change a byte, you would have to copy
that
> > data into RAM, change it, Erase the 8K sector, and Write the 8k
back
> > into the Flash.
> >
> > It is clumsy, but do-able.
> >
> > The other suggestion that someone made about using an SD card is
> > problematic. You would probably use as much RAM doing an SD card
> > storage as you would the 8K Flash sector... IMHO, the best
solution is
> > to put a MicroWire Serial EEPROM on the card, or use an SPI
EEPROM,
> look
> > at:
> >
> http://www.digikey.com/scripts/DkSearch/dksus.dll?Detail?
Ref!70&Row07570&Site=US
> >
> >
> > TomW
> >
> > > These chips are made by Spansion ( a sister company of AMD:
> > > www.spansion. com) and they say they have provided a low level
DMS or
> > > Data Management Software for these particular flash modules,
but for
> > > me, in my limited experience is too complex to use.
> > >
> > > Does anybody have a better idea to store parameters in external
flash
> > > without going through the third party way?
> > >
> > > Thanks a bunch!
> > >
> > > MMK...
> > >
> > >
> >
> >
> >
> > --
> > Tom Walsh - WN3L - Embedded Systems Consultant
> > http://openhardware.net, http://cyberiansoftware.com
> > "Windows? No thanks, I have work to do..."
> > ----------------
>


The 2024 Embedded Online Conference