Hi, I'm new to micro controllers and have started learning programming PICs using assembly language and I was wondering if anybody can help me figure out with something:
I'm trying to use pin RB0 on the 16F877a as my interrupt source to increment the contents of a register (general purpose register named SECTION_SELECT) whenever I press a button connected to RB0 in my ISR and the main program moves the contents of SECTION_SELECT into port D. I tried simulating the code and it works fine, port D increments and returns to 0 after 5 presses. It basically counts from 0 to 5.
When I tried prototyping the circuit, port D doesn't go through the cycle properly. I even cleared the registers i'm using in my headers just to be sure, and put a delay in my ISR before the retfie instruction. Here's my ISR:
;**********************************************
MOVWF W_TEMP ;Copy W to TEMP register
SWAPF STATUS,W ;Swap status to be saved into W
CLRF STATUS
MOVWF STATUS_TEMP ;Save status to STATUS_TEMP register
;**********************************************
BTFSC MODE,0
GOTO SECTION_ZERO
INCF FSR
INCF SECTION_SELECT
BTFSC SECTION_SELECT,2
BTFSS SECTION_SELECT,0
GOTO EXIT
GOTO ISR_ALL
ISR_ALL BSF MODE,0
GOTO EXIT
SECTION_ZERO BCF MODE,0
MOVLW 20h
MOVWF FSR
CLRF SECTION_SELECT
;**********************************************
;EXIT ISR/RESTORE
EXIT BCF INTCON,1
SWAPF STATUS_TEMP,W ;Swap STATUS_TEMP register into W
;
MOVWF STATUS ;Move W into STATUS register
SWAPF W_TEMP,F ;Swap W_TEMP
SWAPF W_TEMP,W ;Swap W_TEMP into W
;**********************************************
CALL DELAY
RETFIE
Though since the code works fine in simulations, I'm thinking it's more of a problem with the hardware, though aside from the basic circuitry required by the PIC, all i've done is add a switch to RB0 to trigger the interrupt. Any ideas on why the circuit doesn't work on the breadboard? Thanks in advance