So I've got some code where the clock part functions but the external interrupt doesn't. The microcontroller counts up in binary on 4 LCDs, and should stop counting on the interrupt which comes on RA5. Unfortunately, nothing happens when I ground RA5. Thoughts?
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Display
W_Save
STATUS_Save
endc
org 0
goto init
ISR:
movwf W_Save
movf STATUS,w
movwf STATUS_Save
btfss PORTA,5 ;test bit, skip if set
goto ExitISR
btfsc PORTA,5
goto Start_Stop
clrf Display
goto ExitISR
Start_Stop:
clrf RABIF ;clear flag
bcf OPTION_REG,PSA ;prescaler is assigned to the Timer0 module
ExitISR:
movf STATUS_Save,w
movwf STATUS
swapf W_Save,f
swapf W_Save,w
retfie
init
banksel OSCCON ;select oscillator control
bcf OSCCON,6 ;set postscaler to 250 kHz
bsf STATUS,RP0
movlw b'00000111' ; configure Timer0. Sourced from the Processor clock;
movwf OPTION_REG ; Maximum Prescaler
clrf TRISC ; Make PortC all output
clrf Display
bcf STATUS,RP0
bsf INTCON,7 ;global interrupt enabled
banksel PORTA
bsf TRISA,5
bsf IOCA,5 ;interrupt on change enabled
;btfss PORTA,5 ;test bit, skip if set
ForeverLoop:
btfss INTCON,T0IF ; wait here until Timer0 rolls over
goto ForeverLoop
bcf INTCON,T0IF ; flag must be cleared in software
incf Display,f ; increment display variable
movf Display,w ; send to the LEDs
movwf PORTC
goto ForeverLoop
end
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Display
W_Save
STATUS_Save
endc
org 0
goto init
ISR:
movwf W_Save
movf STATUS,w
movwf STATUS_Save
btfss PORTA,5 ;test bit, skip if set
goto ExitISR
btfsc PORTA,5
goto Start_Stop
clrf Display
goto ExitISR
Start_Stop:
clrf RABIF ;clear flag
bcf OPTION_REG,PSA ;prescaler is assigned to the Timer0 module
ExitISR:
movf STATUS_Save,w
movwf STATUS
swapf W_Save,f
swapf W_Save,w
retfie
init
banksel OSCCON ;select oscillator control
bcf OSCCON,6 ;set postscaler to 250 kHz
bsf STATUS,RP0
movlw b'00000111' ; configure Timer0. Sourced from the Processor clock;
movwf OPTION_REG ; Maximum Prescaler
clrf TRISC ; Make PortC all output
clrf Display
bcf STATUS,RP0
bsf INTCON,7 ;global interrupt enabled
banksel PORTA
bsf TRISA,5
bsf IOCA,5 ;interrupt on change enabled
;btfss PORTA,5 ;test bit, skip if set
ForeverLoop:
btfss INTCON,T0IF ; wait here until Timer0 rolls over
goto ForeverLoop
bcf INTCON,T0IF ; flag must be cleared in software
incf Display,f ; increment display variable
movf Display,w ; send to the LEDs
movwf PORTC
goto ForeverLoop
end