Hard to say for sure, but with it working for months at a time, I wouldn't suspect anything in the software.
A couple things I can see that might cause problems ...
You are charging the 3V batteries from a 12v source with only a diode and resistor in series.
That's going to overcharge the batteries severely, and I'm surprised they haven't blown up yet. Then when the voltage gets too high, it'll pass right through to VCC raising the voltage above the F84A's limit.
Then if main power is lost, the F84A will be powered by only 3.6V, which is below the 4v minimum for an F84A.
The F84A doesn't have a Brown-out detector, so it won't reset or anything when the voltage is too low.
Voltages outside the normal operating range can cause just about anything to happen (randomly).<hr>
Lowering the resistor value to MCLR, with a small capacitor to ground may help reduce spurious resets, if that's where it's coming from.
Also, this isn't part of the TMR0 problem, but you shouldn't have a switch on the same pins used for an output. It's a dead short to VCC when the switch is pressed. Maybe with some resistors in series to limit the current, but straight to VCC like that, not a good idea.
<br>
Bookmarks