Store long integer in Flash memory


i have program arduino duemilanove counting pulse inputs.  if arduino has restart 1 reason or another, lose counter value.  i store counter value flash memory, when arduino starts after losing power or something, read counter value flash memory , start counting left off.  i read documentation on progmem, can't work.

below simple code tried store , read long integer in flash.  but returns 65535 instead of 80000.  i tried integer (not long), doesn't work.  what want read value in setup() section, , write value in loop() section.


code: [select]

#include <avr/pgmspace.h>

void setup()
{
 serial.begin(57600);
}

void loop()
{
progmem  prog_int32_t charset  = 80000;
long pulsecounter;

pulsecounter = pgm_read_word_near(charset);
serial.println(pulsecounter);
delay(2000);
}

code: [select]
pulsecounter = pgm_read_word_near(charset);

shouldn't there '&' operator in there somewhere?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Store long integer in Flash memory


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums