Page 1 of 1

PROGMEM simple explanation

Posted: Wed Jun 02, 2010 7:48 am
by sdisselhorst
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?

Re: PROGMEM simple explanation

Posted: Wed Jun 02, 2010 11:15 am
by felis
You can't write to PROGMEM. Try EEPROM instead if your micro has it.

Re: PROGMEM simple explanation

Posted: Wed Jun 02, 2010 2:12 pm
by sdisselhorst
OK. I guess that's easier. Thanks!