Complete the code to enable global interrupts.
#include <avr/interrupt.h> int main() { sei(); // Enable global interrupts [1]; while(1) {} return 0; }
The sei() function enables global interrupts in AVR microcontrollers.
Complete the code to define an interrupt service routine (ISR) for TIMER1 overflow.
#include <avr/interrupt.h> ISR([1]) { // ISR code here }
The ISR for TIMER1 overflow uses the vector TIMER1_OVF_vect.
Fix the error in the ISR declaration to allow nested interrupts by enabling global interrupts inside the ISR.
ISR(TIMER2_OVF_vect) {
[1](); // Enable nested interrupts
// ISR code
}Calling sei() inside an ISR enables nested interrupts by setting the global interrupt flag.
Fill both blanks to create a nested interrupt safe ISR that enables global interrupts and clears the interrupt flag.
ISR(ADC_vect) {
[1](); // Enable nested interrupts
ADCSRA [2] (1 << ADIF); // Clear interrupt flag
}Inside the ISR, sei() enables nested interrupts. The interrupt flag is cleared by setting the ADIF bit using |=.
Fill all three blanks to implement a nested interrupt safe ISR that enables global interrupts, clears the interrupt flag, and increments a counter.
volatile uint8_t count = 0; ISR(INT0_vect) { [1](); // Enable nested interrupts EIFR [2] (1 << INTF0); // Clear interrupt flag [3]++; // Increment counter }
Inside the ISR, sei() enables nested interrupts, EIFR |= (1 << INTF0) clears the interrupt flag, and count++ increments the counter.