Complete the code to declare an ISR function correctly.
void [1](void) {
// ISR code here
}The ISR function should be declared with the correct name or attribute depending on the platform. Here, ISR is the correct placeholder for the interrupt service routine.
Complete the code to keep the ISR short by only setting a flag.
volatile int flag = 0; void ISR(void) { [1] = 1; }
In ISR best practices, keep the ISR short by setting a flag variable to signal the main program.
Fix the error in the ISR by disabling nested interrupts.
void ISR(void) {
[1]();
// ISR code
}To avoid nested interrupts causing issues, disable interrupts at the start of the ISR.
Fill both blanks to safely update a shared variable in ISR and main code.
volatile int count = 0; void ISR(void) { [1](); count++; [2](); }
Disable interrupts before updating shared variables and enable them after to avoid race conditions.
Fill all three blanks to implement a flag check and clear in main loop and ISR.
volatile int flag = 0; void ISR(void) { [1] = 1; } int main(void) { while(1) { if ([2] == 1) { // handle event [3] = 0; } } }
The ISR sets the flag to 1. The main loop checks the flag and clears it after handling the event.