001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053 | ;************* Edge LED timer process *****************
edge_timer
bsf status,rp0 ;Change to Bank1
movlw b'00000111' ;TOCS/PSA=0,PS=111
movwf option_reg ;Set OPTION_REG
bcf status,rp0 ;Change to Bank0
movlw d'0' ;Set Hard timer(26msec)
movwf tmr0 ;Set TMR0
movlw d'255' ;Set Soft count
movwf h_timer ;Save soft count
movlw h'a0' ;GIE=1,TOIE=1
movwf intcon ;Interruption enable
return
;--------------- Interruption processing --------------
int
movwf w_save ;Save W register
movf status,w ;Read STATUS reg
movwf s_save ;Save STATUS reg
bcf status,rp0 ;Change to Bank0
btfsc intcon,t0if ;Time out interruption ?
goto timer_int ;Jump to Timer process
;------------ END of Interruption Process --------------
int_end
movf s_save,w ;Read saved STATUS reg
movwf status ;Recover STATUS reg
swapf w_save,f ;Read saved W register
swapf w_save,w ;Recover W register
retfie
;----------- Time-out interruption Process ------------
timer_int
bcf intcon,t0if ;Clear timer int flag
movlw d'0' ;Set Hard timer(26msec)
movwf tmr0 ;Set TMR0
decfsz h_timer,f ;Time over ?
goto int_end ;No. Retry
movlw d'255' ;Set Soft count
movwf h_timer ;Save Soft count
;------------------ Switch Process --------------------
btfsc portb,7 ;RB7 = 0(Left) ?
goto timer_right ;RB7 = 1(Right)
movf portb,w ;Read portb
iorlw h'80' ;Set right data
movwf portb ;Output data
goto int_end
timer_right
movf portb,w ;Read portb
andlw h'7f' ;Set left data
movwf portb ;Output data
goto int_end |