title: PIC16F84_A Interrupt not working
body: <p>Just started learning PIC microcontrollers. For some reason, <code>PORTB</code> remains <code>0x00</code> and interrupt never occurs. </p>
  
  <pre><code>;*** COUNTER WITH INTERRUPT ***
  ;***** PIC16FA4_A *************
  
  ORG     0H
  
  STATUS  EQU 03H
  PORTA   EQU 05H
  PORTB   EQU 06H
  TRISA   EQU 85H
  TRISB   EQU 86H
  INTCON  EQU 0BH
  COUNT   EQU 0CH
  COUNT1  EQU 08H
  COUNT2  EQU 09H
  
  GOTO MAIN
  
  ;** INTERRUP ROUTINE **
  
  ORG     04H
  INCF    COUNT,1
  CLRF    PORTB ; CLEAR RBO
  MOVLW   0AH
  SUBWF   COUNT
  BTFSS   STATUS,0 ;TEST FOR CARRY FLAG
  GOTO    GO_ON
  GOTO    CLEAR
  
  GO_ON   
  BCF     INTCON,1
  RETFIE
  
  CLEAR   
  CLRF    COUNT
  BCF     INTCON,1
  RETFIE
  ;** END OF INERRUPT ROUTINE **
  
  MAIN 
  BSF     INTCON,7; GLOBAL INTERRUPT ENABLE
  BSF     INTCON,4; RB0 INTERRUPT ENABLE
  BCF     INTCON,1; CLEAR INTERRUPT FLAG JUST IN CASE IT IS ON
  
  BSF     STATUS,5
  MOVLW   00H     ;ALL RA PINS AS OUTPUT PINS
  MOVWF   TRISA
  MOVLW   01H     ;RB0 PIN AS INPUT PIN
  MOVWF   TRISB 
  BCF     STATUS,5
  
  LOOP
  MOVFW   COUNT
  MOVWF   PORTA   ;PUT COUNT IN PORTA
  CALL    DELAY   ;DELAY
  MOVLW   01H     
  MOVWF   PORTB   ;SET RB0
  ;EXPECT PROGRAM CONTROL TO GO TO 04H (ORG) BUT IT DOESN'T
  ;ALSO, USING THE WATCH OPTION IN DEBUGGER, PORTB STAYS 0H
  ;CAN ANYONE HELP?
  
  GOTO    LOOP
  
  DELAY
  LOOP1   
  DECFSZ  COUNT1,1
  GOTO    LOOP1 
  LOOP2
  DECFSZ  COUNT2
  GOTO    LOOP2
  RETURN      
  
  END
  </code></pre>
  
  <p>Circuit:<br>
  <a href="https://i.stack.imgur.com/J7caf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J7caf.png" alt="enter image description here"></a></p>