使用ASSEMBLY在PIC16F84A上中断,当RB0中断时将RA1变为高电平

时间:2018-07-01 09:07:24

标签: assembly interrupt

当我按下按钮(中断)时,RA1不会打开。

RA0将一直闪烁,它已经在主机中设置了。

Image to my hardware layout

这是将cpu重定向到isr的代码:

ORG 000H        ; reset vector
GOTO MAIN       ; jump to label main during reset or startup
ORG 004H        ; interrupt vector
GOTO INT_RTN        ; jump to label INT_RTN or ISR               

这是我初始化MCU的方式:

 BSF STATUS, RP0         ; initialize PIC    
 CLRF TRISA  
 MOVLW 01H                   
 MOVWF TRISB                 
 MOVLW 0CH                       
 MOVWF OPTION_REG        
 BSF OPTION_REG, 6      ; interrupt event during rising edge
 BCF INTCON, INTF       ; clear the RB0/INT interrupt flag
 BSF INTCON, INTE       ; unmask (enable) RB0/INT interrupt source
 BSF INTCON, GIE        ; enable all unmasked interrupt 
 BCF STATUS, RP0        ; set register bank to 0    

这是处理中断的代码:

INT_RTN BCF INTCON, GIE     ; disable all unmasked interrupt to prevent 
                            ;interrupt overriding
        BTFSS INTCON, INTF  ; check the RB0/INT interrupt ?ag is ‘1’ 
                            ;  (interrupt source from RB0/INT)
        GOTO EXIT           ; exit ISR if not RB0/INT interrupt
        BSF PORTA, 1            ;sets RA1 to 1 
EXIT    BSF INTCON,  GIE        ; enable all unmasked interrupt
        RETFIE                  ; return from interrupt routine

0 个答案:

没有答案
相关问题