00016R1.asm Source Code
©
2005 Microchip Technology Inc.
DS51551A-page 21
timerh = 0x17 ;on timer high byte
timerl = 0x18 ;on timer low byte
;bits used in the flag variable
new_mode = 7 ;when set a debounced user keypress has been detected
timer_ena = 6 ;when clear the debounce timer will not increment
;GPIO pins
button = 3 ;mode select button
pwm = 0 ;pwm output
;other
TO EQU H’0004’
PD EQU H’0003’
GPWU EQU H’0007’
GPPU EQU H’0006’
COUTEN EQU H’0006’
CMPT0CS EQU H’0004’
CWU EQU H’0000’
org 0x00
goto reset
org 0x10
reset nop
nop
bcf OSCCAL, FOSC4 ; GP2/T0CKI/COUT applied to GP2 pin
init_ports movlw 0x01 ;initalize mode, upon wake up led will be at low intensity
movwf mode
;
movlw b’00001111’ ;configure for wake on port change
OPTION
;
movlw b’01010011’ ;disable the comparator
movwf 0x07 ;write to CMCON0
;
clrf GPIO
movlw 0x0E
tris GPIO ;configure port
;
bcf STATUS, GPWUF
btfsc STATUS, CWUF ;test for wake up or reset
goto wake
btfsc STATUS, GPWUF
goto wake
btfss STATUS, TO
goto wake
btfss STATUS, PD
goto wake
goto init_vars ;initialize vars
init_vars movlw 0xFF
movwf timerh
movwf timerl
;
movlw led_hi_on ;calculate off times based on time remaining in
PWM period
TABLE C-1:
00016R1.ASM (CONTINUED)