Hi there,
Using the PIC16F690, I am having a problem with the following interrupt code which should toggle RC0 upon a button press:
It interrupts fine, but using the stimulus tool, when I get to line
I see that 1111 is moved into wreg (even though PORTA was clear!) and the flag is not cleared thereafter.
Please could you help?
Using the PIC16F690, I am having a problem with the following interrupt code which should toggle RC0 upon a button press:
Rich (BB code):
org 0x04
; Dobounce the switch by adding ~5ms delay
movlw .255
movwf Count1
movlw .7
movwf Count2
Loop:
decfsz Count1, f
goto Loop
decfsz Count2, f ; outer loop 7 times (~5.5 ms)
goto Loop
; clear flag and check for double interrupts
movlw 0x00
movf PORTA, w ; read PORTA to w (end mismatch condition)
bcf INTCON, RABIF ; clear flag
btfsc PORTA, 3 ; Check for double interrupt (i.e. button released)
retfie
; toggle port and set return/retfie
movlw b'00000001'
xorwf PORTC, f ; toggle the LED
btfsc PORTC, 0 ; alternate between retfie and return (to test WDT)
retfie
return
Rich (BB code):
movf PORTA, w ; read PORTA to w (end mismatch condition)
Please could you help?
Last edited: