17.1.2 Interrupts During Doze
System behavior for interrupts that may occur during Doze mode are
configured using the ROI and DOE bits. Refer to the example below for details about system behavior in
all cases for a transition from Main to ISR back to Main.
Doze Software Example
// Mainline operation
bool somethingToDo = FALSE;
void main() {
initializeSystem();
// DOZE = 64:1 (for example)
// ROI = 1;
GIE = 1; // enable interrupts
while (1) {
// If ADC completed, process data
if (somethingToDo) {
doSomething();
DOZEN = 1; // resume low-power
}
}
}
// Data interrupt handler
void interrupt() {
// DOZEN = 0 because ROI = 1
if (ADIF) {
somethingToDo = TRUE;
DOE = 0; // make main() go fast
ADIF = 0;
}
// else check other interrupts...
if (TMR0IF) {
timerTick++;
DOE = 1; // make main() go slow
TMR0IF = 0;
}
}
Note: User software can change the DOE
bit in the ISR.