If you only want to figure out longer or shorter than 5 seconds maybe you can use 2 pins. One I/O pin and one AD pin.
Connect both the AD pin and the I/O pin to the + side of a capacitor and then parallell to this capacitor also connect a resistor, both the resistor and cap connect to ground.
When the pic starts up you read the AD value to see how much the capacitor has discharged. Then you turn on the I/O pin to charge the capacitor full and keep the capacitor charged until you power off the PIC. Then the resistor that is parallell to the cap will discharge it.
By choosing different values on the capacitor and resistor you can get different discharge times. This combined with the AD value will give you a quite good clue how long the PIC has been off.
If you dont have any AD avaliable then you might be able to just use a normal digital i/o. If the cap has a high voltage (it has been dischared a short time) the input would read as a "1", if it is discharged for a longer time till will read as a "0". This will be a much less accurate way. Read the input, guess the time, and turn on the pin as an output to re-charge the cap.




Bookmarks