The following code modification fixes the problem. The idea is a double set of the MCLR reset flag. Electrical noise tends to disrupt the initial condition of the MCLR bit so a double set is needed:
Code:
if PCON.1 = 0 then 'when por reset has occurred
PCON.3 = 1 'set mclr flag
PCON.1 = 1 'set por flag
endif
if PCON.3 = 0 then 'when mclr reset has occurred
PCON.3 = 1 'set mclr flag
goto current 'jump over data display
endif
This is working nearly 100% of the time, unless the noise environment is very,very severe.
The fix is posted here for future reference.
Bookmarks