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