Skip to content
RED SAGSkills
easy5 pts · first answer countsembedded-cinterrupts

Why use volatile

A flag is set inside an interrupt handler and checked in the main loop. Why should it be declared volatile?

volatile bool data_ready = false;

void UART_IRQHandler(void) { data_ready = true; }

int main(void) {
    while (!data_ready) { }
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions