PROGMEM simple explanation

Your source for all things Atmel.

Moderator: phalanx

Post Reply
sdisselhorst
Posts: 31
Joined: Sat Feb 06, 2010 10:04 pm

PROGMEM simple explanation

Post by sdisselhorst » Wed Jun 02, 2010 7:48 am

I am having some trouble with PROGMEM. All I want is to store a few unsigned integers into nonvolatile memory. Wht would be an example of the code for this? I have tried the following:

I am getting a value "calval" by using a potentiometer and the map command.
I want to store the value so my program can use it later.
I want this value to survive powering down.
I have tried storing the value using this:
prog_uint16_t ppgmainmem[] PROGMEM = (calval);
is this right to store it?
and then to retrieve it I have tried:
ppgmain = pgm_read_byte(ppgmainmem);
but it doesn't give me the right value, I think.
The stored value, should be , for example 29, but when I print it out it is only a 2.
Any helpers?

felis
Posts: 183
Joined: Sat May 27, 2006 5:43 pm
Location: 10 miles east of SFE
Contact:

Re: PROGMEM simple explanation

Post by felis » Wed Jun 02, 2010 11:15 am

You can't write to PROGMEM. Try EEPROM instead if your micro has it.
/felis

sdisselhorst
Posts: 31
Joined: Sat Feb 06, 2010 10:04 pm

Re: PROGMEM simple explanation

Post by sdisselhorst » Wed Jun 02, 2010 2:12 pm

OK. I guess that's easier. Thanks!

Post Reply