刚开始用PIC 手头的片子是16c73 自己写的练习小程序 可是到这中断怎么也进不去 t0if溢出的时候 要不跑飞 要不直接跳过去 找了一小天了,水平太菜 还望DX指教程序如下: 仿真器用的是wave6000 有人说他的定时器不好用 有人用过吗 ? include "test.inc" org 00h bcf intcon,gie btfsc intcon,gie goto $-2 goto main
org 04h ;====================================================== ; 中断服务程序 ;====================================================== interrupt: movwf temp_w
swapf status,w movwf temp_status
movf fsr,w movwf temp_fsr
movf pclath,w movwf temp_pclath ;------------------------------------------------------------------- ;中断查询 btfsc intcon,t0if goto t0int ;bcf intcon,t0if btfsc pir1,tmr1if goto t1int ;bcf PIR1,TMR1IF t0int: call display bcf intcon,t0if goto recover t1int: call led_g bcf intcon,tmr1if goto recover
;-------------------------------------------------------------------- recover: movf temp_pclath,w movwf pclath
movf temp_fsr,w movwf fsr
swapf temp_status,w movwf status
movf temp_w,w
retfie ;======================================================== ; 中断查询执行 ; ; ;========================================================
main:
;timer1int: ;clrf t1con ;clrf tmr1h ;clrf tmr1l
;clrf intcon
;bsf status,rp0 ;clrf pie1 ;bcf status,rp0 ;clrf pir1 ;movlw 00110000h ;movwf t1con ;bsf t1con,tmr1on
timer0int: clrf tmr0 clrf intcon bsf status,rp0 movlw 01001011b movwf OPTION_REG bcf status,rp0
bsf intcon,t0ie
bsf intcon,peie bsf intcon,gie
protaint: bsf status,rp0 movlw 07h ;配置 adcon1 movwf adcon1 bcf status,rp0
bsf status,rp0 movlw 0f8h ;配置porta 012-o 345-i movwf trisa bcf status,rp0
other_int: clrf led_flag
main_pro:
nop nop nop nop nop
goto main_pro
|