AT91SAM7S Flash as general purpose NV memory

Hi,

Is it possible to use the AT91SAM7S internal flash memory for general purpose non volatile storage?

I mean: suppose you have a buffer declared in C, like this:

char myBuff[100];

During program execution you write and read data from myBuff. Suddenly the system is powered off. Once the system is powered on again, I want to have the contents of myBuff intact, holding the values stored the last time I wrote (at runtime) to it, prior to power off.

Is that possible? If so, how?

Regards.

Reply to
jaac
Loading thread data ...

No, unless you write your own compiler, the buffer will be in sram, not flash.

Reply to
linnix

plus you need to read the data sheet, as FLASH writes often have their own caveats. You cannot read-while-write of the same Flash.

Some chips have dual Flash planes, so you run in one, while writing to the other. Some chips pause the core during write ( Interrupts OFF) Some chips expect the write code to run in RAM. If the power fails DURING write, you have undefined FLASH content.

-jg

Reply to
Jim Granville

Yes.

No, doing it like this isn't going to be feasible. The problem is that C, as a programming language, has no concept of non-volatile storage. It only treats ordinary RAM and, to some extent, ROM (via the 'const' qualifier).

That's where the problem presents itself most prominently. C generally gives you no control over how exactly it will access that memory, so there's no way to preven the power from going off right in the middle of a write access, leaving you with corrupted data.

A function-like interface to the NV buffer will work better in the long run.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

... snip ...

Yes it does. It is called a FILE.

--
"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety." 
 Click to see the full signature
Reply to
CBFalconer

How?

Fully understood... The question in the "how, then?"

It would be very helpful if someone here (maybe Ulf Samuelson from Atmel, or Hans-Bernhard, or somebody else) provides some code to start with.

I understand that the compiler does not allow to do this directly, and that I will need to write a custom routine to do it (like sending data to an external EEPROM or Flash memory), but I don't know where to start.

All your help is very welcome.

Regards.

JaaC

Reply to
jaac

Well, I just did a similar thing for an ATmega162. And I started reading the datasheet, which also provides code samples.

Couldn't find any code sample in the SAM datasheet though, but Atmel has an application note where the SAM's flash is used as an USB drive, including code.

Meindert

Reply to
Meindert Sprang

Where is the code? Most I can get

formatting link
is this:

REMARK: THE MASS STORAGE & FILE SYSTEM PROJECT CAN BE DELIVERED UNDER NDA ONLY.

What can be downloaded is an .exe file, with some .bin and no source code

From the Atmel website

formatting link
, one gets this:

Demo for AT91 USB Mass Storage module and AT91 FAT File System module (72 KB, updated 11/05)

- Can be downloaded here (click on icon)

- Download the User Guide (Mass Storage and File System Demo for AT91SAM7S-EK Development Board)

- Download the source code using a registration form

Clicking the last line sends one to:

formatting link

But selecting "I Agree to these terms" and then "Valid" leads to nowhere!!!

Can someone help?

Thanks

*** Posted via a free Usenet account from
formatting link
***
Reply to
Jaime Andres Aranguren Cardona

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.