RB0/INT 16F84a Programing Problem
Posted: Fri Jan 09, 2009 12:48 pm
I'm hoping someone on this forum might be able to help me with programming the external interrupt RB0/INT on the PIC16F84a. I'm using the V2 development board with 'Assembly for PICMicro' V2 CD but that shouldn't be the problem. All the exercises in the tutorials functions correctly. Below I have created a very simple program that should initialise the interrupt and light the A0 LED. When a RB0 interrupt is triggered it should call the interrupt routine that turns of the LED. It's that simple but I can't make it work. Can anyone see an obvious problem that I have missed. Any help would be much appreciated.
Cheers
Graham
; The following line embeds configuration data into the PICmicro
__CONFIG H'3FF9' ; xt mode
; At start LED A0 should illunimate. If RB0 is triggered this should
; call the ISR and turn off the LED.
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include "C:\PROGRA~1\MPLAB\P16F84a.INC"
org 0
goto start
org 4
bcf STATUS,RP0 ;goto bank 0
movlw 0x00
movwf PORTA ;turn off LED A0
bcf INTCON,INTF ;clear interrup flag
retfie
start
bcf INTCON,INTF ;clear interrupt flag
bsf INTCON,INTE ;enable RB0 interrupt
bsf INTCON,GIE ;enable global interrupt
bsf STATUS, RP0 ;goto bank 1
movlw 0xff
movwf TRISB ;config portb as inputs
movlw 0x00
movwf TRISA ;config porta as outputs
bcf STATUS, RP0 ;goto bank 0
movlw 0x01
movwf PORTA ;turn on LED A0
wait
movlw 0x01 ;loop
goto wait
END
Cheers
Graham
; The following line embeds configuration data into the PICmicro
__CONFIG H'3FF9' ; xt mode
; At start LED A0 should illunimate. If RB0 is triggered this should
; call the ISR and turn off the LED.
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include "C:\PROGRA~1\MPLAB\P16F84a.INC"
org 0
goto start
org 4
bcf STATUS,RP0 ;goto bank 0
movlw 0x00
movwf PORTA ;turn off LED A0
bcf INTCON,INTF ;clear interrup flag
retfie
start
bcf INTCON,INTF ;clear interrupt flag
bsf INTCON,INTE ;enable RB0 interrupt
bsf INTCON,GIE ;enable global interrupt
bsf STATUS, RP0 ;goto bank 1
movlw 0xff
movwf TRISB ;config portb as inputs
movlw 0x00
movwf TRISA ;config porta as outputs
bcf STATUS, RP0 ;goto bank 0
movlw 0x01
movwf PORTA ;turn on LED A0
wait
movlw 0x01 ;loop
goto wait
END