Complete the code to declare a variable that can change unexpectedly in an ISR.
volatile int [1] = 0;
The variable counter is declared as volatile because it can be changed inside an ISR.
Complete the code to correctly declare a flag variable modified inside an ISR.
volatile [1] flag = 0;
The flag is declared as a volatile int because it is modified in an ISR and used in main code.
Fix the error in the ISR by correctly declaring the variable as volatile.
void ISR_Handler() {
[1] count;
count++;
}The variable count must be declared as volatile int to ensure the compiler does not optimize away accesses in the ISR.
Fill both blanks to declare and use a volatile flag in main and ISR.
volatile int [1] = 0; void ISR() { [2] = 1; }
The variable flag is declared volatile and set to 1 inside the ISR.
Fill all three blanks to declare a volatile counter, increment it in ISR, and check it in main.
volatile int [1] = 0; void ISR() { [2]++; } int main() { if ([3] > 0) { // handle event } return 0; }
The variable event_count is declared volatile, incremented in ISR, and checked in main.