I just wanted to make sure this was a good idea before I started into the code.
I have a total of 5 bytes of data that I want to log 3 (maybe 4) times a minute to my PC via serial. I want to use any unused flash on the chip to buffer the data in case the serial connection breaks, and if I'm doing the math right, I should have around 12 hours of buffer time to work with, which I think is ample for my needs.
My question is, all of the progmem stuff I'm reading pertains to reading strings that are set at compile time, and I'm unsure if I am allowed to write to progmem during runtime. Can anyone confirm if what I want to do is possible?
It's not practical to write to the flash program memory from your program. Only the bootloader is allowed to do that.
The flash memory also has a limited number of write cycles allowed -- 10,000, I think. The limit is not a problem for flashing your programs, but could be quickly used up by a program.
You could use the internal EEPROM, but if your chip has 1K of internal EEPROM, you will have less than an hour of logging at 1200 bytes/hour.
External serial EEPROMs are cheap and easy to interface. That may be your best bet if you need longer logging times.
The internal EEPROM also has write limits, so you would want to use it only if the serial connection went down. You would not want to use it continuously.
Humm, I was afraid it was not going to be so easy. I was under the impression that flash write cycles were in the astronomical "dont worry about it" range.
External EEPROM's are an option, but if I'm going that route, I might as well go full blown SDHC, and let it run for months. As far as I know, SD writing does not require any extra hardware besides a breakout board. I will look into that next, and if I get scared, I will fall back on EEPROM.
I suppose I might as well post in this thread since it's somewhat related.
I want to store 3 integers in non-volatile memory that can be read everytime the arduino is reset. Then if a function calls for it, update the value of these integers. That way, the next time the Arduino is reset, it'll use the now updated values.
PROGMEM doesn't seem to be the answer. Since it has to write something to SRAM before it can be read. But doing this will just overwrite the values in memory.
The goal is for the Arduino to store settings that can be user adjusted. Then re-stored for further use upon next reset.
Can the Arduino do this? Is there a way to read/write to a specific memory address? Hopefully in a manner that won't let the values get overwritten by an unintended function?