This is quite simple... consider the appended circuit...
Normal power for the PIC is supplied via D1 to the PIC's +5v Power Supply, eg 78L05 or whatever you have. R1/R2 is a potential divider to give you no more than 5v cut down from the maximum vehicle supply. You can have say a 4.7v Zener if you feel uneasy in lieu of R2 to make sure the PIC never gets anything over 5v on it's Power-Fail detect pin.
When the +12v Supply is switched off, the pic detects this via R1/R2, however charged Capacitor C1 keeps it running for another 500mS (or whatever's needed), which is enough time to save the appropriate Data to EEPROM and go into a endless loop waiting for the eventual total Power Loss. Value of C1 will be dependant on your PIC's current draw and how long you need to keep the PIC running after Power-Off.
Melanie
Bookmarks