you are making this very difficult,

every schematic so far is different some are worse than others
the latest is doubtful r17 is too big 3k3 would be more realistic

this is very bad
Name:  pesc1.jpg
Views: 3330
Size:  14.0 KB

given that vin high is vdd*0.8 and vin low is vdd*0.2
a 12 volt input lands slap bang in the middle nowhere land , the slightest bit of noise could swing it either way
r8 should be about 27k

you keep posting code snippets or incomplete fragments that are impossible to evaluate
this is a nonsense , and will continually reset because it has no loop it just wander off into lala land



Code:
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_6 & _WDTCCS_SC
__config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
__config _CONFIG5, _CP_OFF
#ENDCONFIG








OSCCON1=%00000011
OSCCON2=%00000011




trisa = %11101100
trisc = %11111111




ANSELC = 0
ANSELA = 4








DEFINE OSC 4




FET var LATA.4 ' FET output
IG VAR PORTA.5 ' Ignition input
GREEN VAR LATA.0 ' TIMING LED
RED VAR LATA.1 ' FAULT LED




MAIN:
IF ig = 1 THEN
FET = 1
GREEN = 1
ELSE
FET = 0
GREEN = 0
ENDIF
i'm going to let it stew for a few days till you get your act together