ORG 0000H GOTO MAIN ORG 0008H BTFSS INTCON,TMR0IF RETFIE GOTO T0_ISR ORG 00100H
ID: 1846611 • Letter: O
Question
ORG 0000H
GOTO MAIN
ORG 0008H
BTFSS INTCON,TMR0IF
RETFIE
GOTO T0_ISR
ORG 00100H
MAIN BCF TRISB,5
CLRF TRISD
SETF TRISC
MOVLW 0x08
MOVWF T0CON
MOVLW 0xFF
MOVWF TMR0H
MOVLW 0xF2
MOVWF TMR0L
BCF INTCON,TMR0IF
BSF T0CON,TMR0ON
BSF INTCON,TMR0IE
BSF INTCON,GIE
OVER MOVFF PORTC,PORTD
BRA OVER
T0_ISR
ORG 200H
MOVLW 0xFF
MOVWF TMR0H
MOVLW 0xF2
MOVWF TMR0L
BTG PORTB,5
BCF INTCON,TMR0IF
EXIT RETFIE
END
1. interrupt is used for timer control.
(a) Find the two assembly instructions that correspond to the loop until interrupted. Show these two instructions in the answer here; show especially what label is used for the loop (the label used in example 3-9 is AGAIN (and BNZ for jumping) and the label used in example 9-3 is also called AGAIN (and BRA for jumping).
(b) Explain how the interrupt loop can be stopped.
(c) When the poll loop is stopped in example 9-3, which instruction is executed?
(d) When the interrupt loop is stopped (interrupted), which instruction (or function) is executed?
(e) What happens when the code returns from the T0_ISR via RETFIE?
Explanation / Answer
a.)
OVER MOVFF PORTC,PORTD
BRA OVER
These instruction are executed until an interrupt is occured. Once the interrupt is occured the code at the Interrupt service routine is executed and comes back to the these two lines.The label of the loop is OVER.
b.)
the interrupt loop is stopped when an interrupt is occured. after executing all the instructions in the Interrupt service routine the interrupt loop is again started.
c.)
when the poll loop is stopped in example 9-3, BCF T0CON, TMR0ON is executed.
d.)
when the interrupt loop is stopped the PC goes to the interrupt vector location that is 0x8H.
So the instruction BTFSS INTCON,TMR0IF which is at 0x08H is executed when the interrupt loop is stopped(interrupted).
e.)
After exiting the ISR by executing RETFIE, the interrupt loop which was stopped due to interrupt is again started and continue executing.
Please reply if any futher explanation is required.:)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.