PIC16F877A初學(xué)之定時(shí)器中斷篇
程序功能:讓RC口的八個(gè)燈亮65MS滅65MS采用定時(shí)器0中斷來(lái)完成
程序如下:
tmr0 equ 01h
pcl equ 02h
status equ 03h
option_reg equ 81h
iNTCon equ 0bh
portc equ 07h
trisc equ 87h
tmr0_b equ 0
w equ 0
f equ 1
rp0 equ 5
t0if equ 2
w_temp equ 7fh
portc_b equ 23h
flag equ 24h
org 0000h
nop
goto main
org 0004h
tmr0_serv
movwf w_temp
bcf intcon,t0if
movlw tmr0_b
movwf tmr0
btfss flag,0
goto loop0
bcf flag,0
goto loop1
loop0
bsf flag,0
movlw 0ffh
movwf portc
goto retfie_b
loop1
movlw 00h
movwf portc
retfie_b
movf w_temp,w
retfie
main
bsf status,rp0
movlw 0
movwf trisc
movlw 07h
movwf option_reg
bcf status,rp0
movlw 00h
movwf portc
movlw 0a0h
movwf intcon
bcf intcon,t0if
movlw tmr0_b
movwf tmr0
goto $
end
以上程序已經(jīng)運(yùn)行通過(guò)