麻煩哪位大大能幫我看一下程式...
我這個程式是個簡單的跑馬燈程式!
LED由左向右亮,再由右亮回來...
以RB0當外部中斷觸發接腳...
當發生中斷時LED全亮!
我現在的情形是...
跑馬燈OK!
發生中斷LED也全亮!
問題是發生中斷後怎LED就一直亮著?!
沒恢復跑馬燈型態!
不曉得我少考慮了什麼事情?!
還是哪邊程式有錯?!
麻煩哪位好心的大大能花些時間幫我看一下程式...
感激不盡...謝謝!
我的程式如下...
list P=18F252
#include <P18F252.INC>
num equ 0x80
num1 equ 0x81
W_temp equ 0x82
S_temp equ 0x83
B_temp equ 0x84
org 0x00
nop
goto Initial
org 0x08
goto ISR
;************ 初始化 ****************;
Initial:
banksel TRISC
clrf TRISC,0
movlw B'00000001'
movwf LATC,0
bcf INTCON2,INTEDG0,0
bsf INTCON,INT0IE,0
bsf RCON,IPEN,0
bsf INTCON,GIE,0
;*********** LED左移程式 *************;
Left:
call Delay
rlncf LATC,f,0
btfss PORTC,7,0
goto Left
goto Right
;********** LED右移程式 *************;
Right:
call Delay
rrncf LATC,f,0
btfss PORTC,0,0
goto Right
goto Left
;************ 延遲時間 *************;
Delay:
banksel num
movlw .100
movwf num,1
delay_loop
nop
call Delay1
decfsz num,1,1
goto delay_loop
return
;*****************;
Delay1:
banksel num1
movlw .250
movwf num1
delay1_loop
nop
decfsz num1,1,1
goto delay1_loop
return
;*********** 中斷程式 **************;
ISR:
movwf W_temp,0
movff STATUS,S_temp
movff BSR,B_temp
movlw B'11111111'
movwf PORTC
call Delay
bcf INTCON,INT0IF,0
movff S_temp,STATUS
movff B_temp,BSR
swapf W_temp,f
swapf W_temp,w
retfie
end