After a dot->sleep() the Timer runs about three times too fast. E.g.:
#include "mDot.h"
Serial pc(USBTX, NC);
void countdown(int count) {
DigitalOut led(LED1);
Timer timer;
timer.start();
while ( count-- > 0 ) {
printf("Count %d: %d msec\r\n", count, timer.read_ms());
led = 1; wait_ms(150);
led = 0; wait_ms(850);
}
}
int main() {
pc.baud(115200);
mDot* dot = mDot::getInstance();
printf("\r\nmbed-os %d.%d.%d (%d), libxDot %s\r\n",
MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION,
MBED_LIBRARY_VERSION, dot->getId().c_str());
countdown(5);
dot->sleep(1, mDot::RTC_ALARM, false /*no deepsleep*/);
countdown(5);
}
Output:
mbed-os 5.3.2 (133), libxDot 2.0.16-7-ga61aab1-mbed133
Count 4: 0 msec
Count 3: 1001 msec
Count 2: 2003 msec
Count 1: 3004 msec
Count 0: 4006 msec
Count 4: 0 msec
Count 3: 3203 msec
Count 2: 6406 msec
Count 1: 9609 msec
Count 0: 12812 msec
How can I get the Timer run reliable after a dot->sleep()?