list p=12f675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.
cblock 0x20
d1
endc
;**********************************************************************
ORG 0x000 ; processor reset vector
goto init ; go to beginning of program
ORG 0x004 ; interrupt vector location
init:
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
CLRF GPIO ;Init GPIO
MOVLW 07h ;Set GP<2:0> to
MOVWF CMCON ;digital IO
BSF STATUS,RP0 ;Bank 1
CLRF ANSEL ;Digital I/O
MOVLW b'00000001' ;Sets inputs and outputs
MOVWF TRISIO ;and set outputs
BCF STATUS,RP0 ;Bank 0
clrf GPIO
goto main
main:
btfss GPIO,0
call lowtest
btfsc GPIO,0
call hightest
goto main
lowtest:
bsf GPIO,1
call Delay
bcf GPIO,1
bsf GPIO,2
call Delay2
bcf GPIO,2
return
hightest:
bsf GPIO,1
call Delay2
bcf GPIO,1
bsf GPIO,2
call Delay2
call Delay2
bcf GPIO,2
return
Delay
;499994 cycles
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;2 cycles
goto $+1
;4 cycles (including call)
return
Delay2:
;999990 cycles
movlw 0x07
movwf d01
movlw 0x2F
movwf d02
movlw 0x03
movwf d03
Delay_01
decfsz d01, f
goto $+2
decfsz d02, f
goto $+2
decfsz d03, f
goto Delay_01
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
END ; directive 'end of program'