For saving to the EEPROM, choose a PIC with a LVD (Low Voltage Detect) interrupt.
When the power is turned off, the interrupt gets triggered, quickly save to EEPROM while the chip is still running on the capacitor charge.
The rest of the time, the value is available in RAM. No need to save it on every loop.
<br>
Bookmarks