1)You haven't declared last_val
2)If you lose power while writing to the EEPROM your saved value might be corrupt
3)You most likely will shut off power during the pause 1000 – in this case you would not expect to see the same number when you repower up. Say you had PORTB = 28 when the power went down (during the Pause 1000). 28 should be in the EEPROM. When you reapply power, the number 28 is read back and put on PORTB. a few microseconds later you add 1 to that and display the new value, which you see. Therefore 28 !=29.
4)Jerson is right – your eeprom is limited in the number of writes – how about detecting the power loss and writing the value to EEPROM before the power drops out?
5)
Ovbiously I init the eeprom data with a number before taht the pic can run on first time!
Not to me, I don't see it in your code.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Bookmarks