Interrupts Flashcards
What is the defintion of a task?
A distinct activity that is required to be performed
What is an event triggered task?
This is a task that can occur at unpredictable times
What is polling?
This is when you repeatedly check the status of an input to see if it changes
What is the issue with polling?
It wastefully consumes power
What is an edge triggered interrupt?
The interrupt is configured to detect a changing input (from HIGH to LOW or from LOW to HIGH).
Main execution is halted and only when the interrupt is triggered, a side execution is started and then when that is done the microcontroller halts and sleeps again.
What is a hybrid aproach to get button input whilst sleeping the microcontroller?
> Combining interrupts and polling
The microcontroller halts and sleeps and the interrupt is triggered which changes a flag variable
After the flag variable is triggered the microcontroller wakes and resumes and then sees that the flag has changed and execute the required code before sleeping again
What is a time triggered task?
This is when a timer triggers the interrupt
What are the two types of time triggered interrupts?
Ticker = Triggers periodically Timeout = To trigger once
What are the two sleep modes? What is the difference?
sleep()
> System clock is stopped
> Saves dynamic power
> Peripherals continue on working and can generate interrupts
> Woken with timers, serial or external pin interrupt
deepsleep()
> System clock is stopped
> Peripherals and clocks power down
> Only woken using external pin interrupt
How do you declare an event triggered interrupt in c++?
InterruptIn buttonA(PTC7);
How do you structure an event triggered interrupt function and variable?
volitile int g_buttonA_flag = 0; void buttonA_isr();
How do you set a falling edge interrupt?
buttonA.fall(&buttonA_isr);
What is the event triggered interrupt function?
void buttonA_isr() { g_buttonA_flag = 1; }
How do you declare a ticker?
Ticker ticker;
just like an object
How do you structure a ticker interrupt function and variable?
volitile int g_timer_flag = 0; void timer_isr();