Don't write to often to the EEPROM on the same position !
Think about a ring-buffer !
Maybe:
Get the olf value.
Count...
Write the new value to the next position and a checksum out of the new and the old value (asume a fixed value for non-existing old values!). If you reach the end of EEPROM, begin on the first position.
After Power-On
0: store 0 as backup-value.
1: read a value, check checksum.
2: if checksum is ok, store the value as Backup, goto 1
3: if checksum is bad, use the backup-value and exit
Just read to manual !
Maybe you can build hardware to buffer the pic fpr around 10ms to write the eeprom and then turn off. Use the Brown-Out-Reset !!!!
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks