;**********************************************************************
list p=12f629
#include <p12f629.inc>
errorlevel -302
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;**********************************************************************
;Variables
;**********************************************************************
cblock 0x22
count
count1
counta
countb
counter
w_temp
status_temp
endc
;**********************************************************************
;Start
;**********************************************************************
ORG 0x000 ; processor reset vector
goto Main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
;Int Code:
movlw d'255'
call delay
movlw d'255'
call delay
movlw d'255'
call delay
movlw d'255'
call delay
bsf GPIO,4
movlw d'255'
call delay
movlw d'255'
call delay
movlw d'255'
call delay
movlw d'255'
call delay
bcf GPIO,4
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
bcf INTCON,INTF ;clear GPIO2 flag
retfie ; return from interrupt
; these first 4 instructions are not required if the internal oscillator is not used
Main
call 0x3FF ; retrieve factory calibration value
bsf STATUS,RP0 ; set file register bank to 1
movwf OSCCAL ; update register with factory cal value
bcf STATUS,RP0 ; set file register bank to 0
movlw 0x07 ;turn comparators off
movwf CMCON
bsf STATUS,RP0
movlw b'00000100' ;GPIO 2 is input for INT
movwf TRISIO
bcf STATUS,RP0
;INT Setup:
bsf INTCON,GIE
bsf INTCON,INTE
clrf GPIO
Loop
bsf GPIO,1
bcf GPIO,1
movlw d'255'
call delay
movlw d'255'
call delay
SLEEP
bcf INTCON,INTF
goto Loop
;**********************************************************************
;Delay Routines
;**********************************************************************
delay movwf count1
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
delay_0
decfsz counta,f
goto $+2
decfsz countb,f
goto delay_0
decfsz count1,f
goto d1
retlw 0x00
end