AVR Microcontroller Questions and Answers – Interrupt Programming

This set of AVR Micro-controller Multiple Choice Questions & Answers (MCQs) focuses on “Interrupt Programming”.

1. On reset, what are the contents of the SREG register?
a) 00h
b) ffh
c) 1fh
d) 11h
View Answer

Answer: a
Explanation: On reset, all the interrupts are masked and so the contents of the SREG register is also set to zero as it shows the status of the flags.

2. TIMSK register is used for?
a) knowing the status of the timer count
b) used for masking the interrupts flags of the Timer0, Timer1 and Timer2
c) it is used for enabling all the timer interrupts
d) it is used for resetting the value of the interrupts
View Answer

Answer: b
Explanation: TIMSK is used for masking the interrupt flags of the timers. They mask the bits of the timer flags if the D7 bit of the SREG register is set to 1 or when firstly all interrupts are enabled.

3. Why RETI instruction be the last instruction of ISR?
a) because it returns with carry
b) because it returns to the main program with all the flags of the SREG raised
c) because it returns to the main program where interrupt is generated and set the global interrupt enable bit in SREG
d) none of the mentioned
View Answer

Answer: c
Explanation: When an interrupt occurs, the global interrupt enable bit is cleared. If global interrupt enable is cleared it means interrupts are disabled. RETI instruction must last instruction of ISR because it returns to the main program where interrupt is generated and sets the global interrupt enable bit in SREG.
advertisement
advertisement

4. In AVR what is the ISR address for an external hardware interrupt?
a) 0002h
b) 0004h
c) 0006h
d) all of the mentioned
View Answer

Answer: d
Explanation: The ISR addresses for the external hardware interrupts are 0002h, 0004h, 0006h.

5. What is the address in the interrupt service routine assigned for the timer0 overflow flag?
a) 0012h
b) 000Ah
c) 0016h
d) all of the mentioned
View Answer

Answer: c
Explanation: 0016h is the address in the interrupt service routine assigned for the timer0 overflow flag.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Is the same address is assigned for the timer0 and timer1 overflow flag in the interrupt vector table of the interrupts?
a) true
b) false
c) can’t be determined
d) depends on the situation
View Answer

Answer: b
Explanation: Different addresses are assigned for Timer0 and Timer1 overflow flags in the interrupt vector table. They are 0016h and 0012h for timer0 and timer1 respectively.

7. External hardware interrupts are assigned to which pins of the atmega32?
a) PORTD.2
b) PORTD.3
c) PORTB.2
d) All of the mentioned
View Answer

Answer: d
Explanation: There are three external hardware interrupts in the atmega32 microcontrollers. They are assigned to bits PORTD.2, PORTD.3 and PORTB.2.
advertisement

8. Which register is responsible for handling all the external hardware interrupts?
a) TIMSK
b) GICR
c) MCUCR
d) IVCE
View Answer

Answer: b
Explanation: GICR register is responsible for all the external hardware interrupts in the AVR.

9. By default, INT0-INT2 interrupts are?
a) edge triggered
b) level triggered
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: b
Explanation: By default, INT0-INT2 are the level triggered pulses. The low level of the pulse generates the interrupt.
advertisement

10. What will happen in that condition, if an interrupt occurs while the microcontroller is serving any other interrupt?
a) both the interrupts will be handled simultaneously
b) the interrupt which is being done first will be served first
c) the interrupt that is more priority in the interrupt vector table will be served first
d) the interrupt having low priority in the interrupt vector table will be served first
View Answer

Answer: c
Explanation: If two or more interrupts occur simultaneously then the interrupt that is having more priority in the interrupt vector table will be served first.

Sanfoundry Global Education & Learning Series – Microcontroller.

To practice all areas of Microcontroller, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.