I understand when program flow is inside an interrupt routine
it is necessary to clear the appropriate interrupt flag.
Now i have 2 questions about this:
-Is it important if you do this in the beginning or the end of ISR ?
-Could someone explain what happens if you dont clear it?
Heres an example that clears the flag in the end.
Here's another one ex (microchip) that does it in the beginning
it is necessary to clear the appropriate interrupt flag.
Now i have 2 questions about this:
-Is it important if you do this in the beginning or the end of ISR ?
-Could someone explain what happens if you dont clear it?
Heres an example that clears the flag in the end.
Code:
INT_SERV:
INCF COUNTER, F
BTFSS COUNTER, 0 ; light the appropriate LEDs
BCF PORTB, 4
BTFSC COUNTER, 0
BSF PORTB, 4
BTFSS COUNTER, 1
BCF PORTB, 5
BTFSC COUNTER, 1
BSF PORTB, 5
BTFSS COUNTER, 2
...... other stuff
BCF INTCON, INTF ; clear the appropriate flag
RETFIE ; this also set global interrupt enable
Here's another one ex (microchip) that does it in the beginning
Code:
RTCisr
BANKSEL TMR1H
BSF TMR1H, 7 ; Preload for 1 sec overflow
BCF PIR1, TMR1IF ; Clear interrupt flag
INCF secs, F ; Increment seconds
MOVF secs, w
SUBLW .60
BTFSS STATUS, Z ; 60 seconds elapsed?
RETURN ; No, done
CLRF seconds ; Clear seconds
INCF mins, f ; Increment minutes
MOVF mins, w
... etc
RETURN ; Done