this is what I tried , it works fine
Code:
#CONFIG
cfg = _INTRC_OSC_NOCLKOUT
cfg&= _WDT_ON
cfg&= _PWRTE_OFF
cfg&= _MCLRE_ON
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _BOD_ON
cfg&= _IESO_ON
cfg&= _FCMEN_ON
__CONFIG cfg
#ENDCONFIG
DEFINE OSC 8 ; tells PBP we use a 8 MHZ clock
OSCCON = %01110000
ANSEL = 0 ;set all digital
TRISA = %110100 ; Set RA5,RA4 and RA2 input, rest output
TRISB = %0000 ; PORT B all output
TRISC = %00000000 ; PORT C all output
CM1CON0 = 0 ' Disable comparator 1
CM2CON0 = 0 ' Disable comparator 2
led1 var portc.4
buton1 var porta.4
led1flag var bit
low led1
let led1flag = 0
init:
read 10,led1flag
pause 2
main:
if led1flag = 1 then
high led1
else
low led1
endif
if buton1 = 0 then
let led1flag = 1
goto writetoeeprom
endif
goto main
writetoeeprom:
write 10, led1flag
pause 2
debounce:
if buton1 = 0 then goto debounce
goto init
end
Bookmarks