EmbDev.net

Forum: ARM programming with GCC/GNU tools Can I make use of unused flash area as storage?


Author: Cem Eryasar (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello,

I have to store some runtime values somewhere so that I do not lose them
over power downs and restarts. However on my tiny LPC-2138 board there
is no external EEPROM for my use. Therefore I am thinking of using the
unsued flash area of the 2138 as a tiny file storage segment. From the
chip manual point of view it seems possible with IAP commands. But there
is not much example out there.

Has anybody tried that? Is it useful?
Any ideas for alternatives?

Thanks
Cem

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Cem Eryasar wrote:
> I have to store some runtime values somewhere so that I do not lose them
> over power downs and restarts. However on my tiny LPC-2138 board there
> is no external EEPROM for my use. Therefore I am thinking of using the
> unsued flash area of the 2138 as a tiny file storage segment. From the
> chip manual point of view it seems possible with IAP commands. But there
> is not much example out there.

There is an example for IAP in the file-archive of the LPC2000
yahoo-group. You have to sign up to this group with a yahoo-account to
get access to the file-archive. I have not used this code so far.

For my "T-Clock" project I have implemented an "EEPROM-emulation" inside
the LC2106 flash. See
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/ (files
iap*.*). It's not a very well-structured code and from the days when I
started using LPC controllers but at least it worked in my project and I
know that others used the code too.

> Has anybody tried that? Is it useful?

Obviouly I have tried it for the "T-Clock" and it worked. Be aware the
you have to write a sector (several bytes, depends on LPC) and you have
to delete a flash-bank before you can write new data in a sector of a
bank. At least on an LPC2106 it's not possible to delete only a sector.
It's not a "byte"-access as in an EEPROM.

The read-modify-write approach in the T-Clock-code:

- read a sector from the flash-bank into a buffer
- modify buffer with updated values
- if bank is full erase bank, reset sector-number
- write to next sector in bank (or the first after erase)

Inside the sector I keep track which of the sectors holds the "newest"
values for the read-routine. This is basicly a emulation of an EEPROM of
sector-size bytes. This approach avoids that the bank has to be erased
every time new data gets stored.

> Any ideas for alternatives?

For example an external EEPROM with I2C- or SPI-Interface.


Hope this helps,
Martin Thomas

Author: Cem Eryasar (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi Martin,

> There is an example for IAP in the file-archive of the LPC2000
> yahoo-group. You have to sign up to this group with a yahoo-account to
> get access to the file-archive. I have not used this code so far.
>
> For my "T-Clock" project I have implemented an "EEPROM-emulation" inside
> the LC2106 flash. See
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/ (files
> iap*.*). It's not a very well-structured code and from the days when I
> started using LPC controllers but at least it worked in my project and I
> know that others used the code too.

I looked at your code. You disabled the PLL prior to calling IAP
function. Then after the IAP function you enabled it. Why did you need
that? I did not see anything like that on the LPC2138 user manual.

I wrote a simple test and it runs without a problem so far without
disabling the PLL. I tested the write/erase cycles with and without the
PLL disabling, but I did not notice any difference. The cpu runs at
14Mhz crystal with 2x PLL multiplier.

Thanks
Cem

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Cem Eryasar wrote:
>
> Hi Martin,
>
>> There is an example for IAP in the file-archive of the LPC2000
>> yahoo-group. You have to sign up to this group with a yahoo-account to
>> get access to the file-archive. I have not used this code so far.
>>
>> For my "T-Clock" project I have implemented an "EEPROM-emulation" inside
>> the LC2106 flash. See
>> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/ (files
>> iap*.*). It's not a very well-structured code and from the days when I
>> started using LPC controllers but at least it worked in my project and I
>> know that others used the code too.
>
> I looked at your code. You disabled the PLL prior to calling IAP
> function. Then after the IAP function you enabled it. Why did you need
> that? I did not see anything like that on the LPC2138 user manual.
>
> I wrote a simple test and it runs without a problem so far without
> disabling the PLL. I tested the write/erase cycles with and without the
> PLL disabling, but I did not notice any difference. The cpu runs at
> 14Mhz crystal with 2x PLL multiplier.

Hmm, it has been to long since I have written the code. Maybe there is
something about this in the LPC2106-manual (LPC2106 has "IAP" and
LPC2138 has "IAP2"). IRC the IAP-calls receive the target-frequency as
parameter. I don't know now if this is the frequency "before" or "after"
the PLL. I expect the frequency-information is used for the timing of
the flash write/erase-sequence. Double-check the datasheet about the
IAP-frequency and from where it is sourced.  It may work for you now but
you may also "overclock" something.

Martin Thomas

Author: Mh Tay (lpc2103)
Posted on:

Rate this post
0 useful
not useful
Very old boot loaders for LPC2104/6, LPC2124/2214 are
having problems programming the flash at high frequencies
(40-60Mhz).  Hence, A lot of old examples (like keil example)
shut down PLL when doing the flash programming.
Philips released some bootloader upgrade to get that problem
fixed.

All newer LPC213x/4x, LPC2103 are OK to programming the flash
at any frequencies.
Regards

Author: Cem Eryasar (Guest)
Posted on:

Rate this post
0 useful
not useful
Thanks a lot for all the support.
Really appreciated your time and patience.
Regards
Cem

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.