Hello all,
I have an interesting problem with the new sleep method. I'm trying to set up a recurring timer event, and sleep between each event (to save power). This seems like a fairly typical use-case, but I cannot get it to work beyond the first sleep. I tried to reduce it to the simplest case:
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Timeout to1;
Timeout to2;
void led1_on() { led1 = 1; }
void led2_on() { led2 = 1; }
int main() {
led1 = 0;
led2 = 0;
to1.attach_us(led1_on, 1000000);
to2.attach_us(led2_on, 2000000);
while (1) {
printf("Entering sleep.\n");
sleep();
}
}
The first event fires correctly, and wakes the processor from sleep. The second event does not, however, and only the first LED lights up. The order in which they are attached makes no difference. Also, the same effect is seen using the Ticker class, in that only the first tick event fires.
I'm fairly sure that there's a bug in the sleep implementation, but have I missed something obvious here?
Hello all,
I have an interesting problem with the new sleep method. I'm trying to set up a recurring timer event, and sleep between each event (to save power). This seems like a fairly typical use-case, but I cannot get it to work beyond the first sleep. I tried to reduce it to the simplest case:
The first event fires correctly, and wakes the processor from sleep. The second event does not, however, and only the first LED lights up. The order in which they are attached makes no difference. Also, the same effect is seen using the Ticker class, in that only the first tick event fires.
I'm fairly sure that there's a bug in the sleep implementation, but have I missed something obvious here?