;************************************************* ***********
; Processor: PIC12F683 at 4 MHz using intosc
;************************************************* ***********
#include "P12F683.INC"
;
__config _FCMEN_OFF & _IESO_OFF & _PWRTE_OFF & _BOD_OFF & _MCLRE_OFF & _WDT_OFF & _CP_OFF & _CPD_OFF & _INTOSCIO
;
cblock 0x20
del1
del2
endc
org 0x00
clrf GPIO ;initialise all outputs
clrf CMCON0 ; CMCON0 set GP0, GP1 to analog input, GP2 to I/O and
banksel 0x80 ;select upper register bank
movlw 0x01
movwf TRISIO ;make GP4 output
banksel 0x00 ;select lower register bank
Loop
Bsf GPIO,1 ;led on
;into the w register and then on the port
;****Check if the switch is closed
BTFSC 9AH,0 ;Get the value from PORT A
;BIT 0. If it is a zero
call delay ;a zero, carry on as normal.
;If is is a 1, then add an
;extra delay routine
;****Add a delay
call delay
;****Delay finished, now turn the LED off****
Bsf GPIO,1
;****Check if the switch is still closed
BTFSC 9AH,0 ;Get the value from PORT A
;BIT 0. If it is a zero,
call delay ;carry on as normal.
;If is a 1, then add an
;extra delay routine
;****Add another delay****
call delay
;****Now go back to the start of the program
goto Loop ;go back to Start and turn LED on again
delay
decfsz del1,f ;decrement the low order delay register
goto delay ;go back if it hasn't reached zero
decfsz del2,f ;decrement the high order delay register
goto delay ;go back if it hasn't reached zero
return ;return to where the subroutine was called
end