PIC16F877A初学之定时器中断篇
扫描二维码
随时随地手机看文章
程序功能:让RC口的八个灯亮65MS灭65MS采用定时器0中断来完成
程序如下:
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
以上程序已经运行通过