Description
Description
LowPowerTimeout is broken in mbed-os-5.10.3 and 5.10.4. The LowPowerTimeout will not work properly if the time to fire is set to 3 seconds or greater. If one of the timeouts is less than 3 seconds then all of the timeouts will fire correctly.
Test1:
Code:
`#include "mbed.h"
#define NUM_TIMEOUTS 5
int main() {
Timer timers[NUM_TIMEOUTS];
LowPowerTimeout timeouts[NUM_TIMEOUTS];
for (int i = 0; i < NUM_TIMEOUTS; i++) {
timers[i].start();
timeouts[i].attach_us(mbed::callback(&timers[i], &Timer::stop), 3000000);
}
wait(6); //wait for all timeouts to fire
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
printf("%d : %d \n\r", i, timers[i].read_us());
}
return 0;
}`
Output:
0 : 6000538
1 : 6013045
2 : 6027559
3 : 6042073
4 : 6056589
None of the timeouts fired.
Test 2:
Code:
`
#include "mbed.h"
#define NUM_TIMEOUTS 5
int main() {
Timer timers[NUM_TIMEOUTS];
LowPowerTimeout timeouts[NUM_TIMEOUTS];
timers[NUM_TIMEOUTS-1].start();
timeouts[NUM_TIMEOUTS-1].attach_us(mbed::callback(&timers[NUM_TIMEOUTS-1], &Timer::stop), 2000000);
for (int i = 0; i < NUM_TIMEOUTS - 1; i++) {
timers[i].start();
timeouts[i].attach_us(mbed::callback(&timers[i], &Timer::stop), 3000000);
}
wait(6); //wait for all timeouts to fire
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
printf("%d : %d \n\r", i, timers[i].read_us());
}
return 0;
}`
Output:
0 : 3000504
1 : 3000467
2 : 3000431
3 : 3000399
4 : 2000352
All fired correctly with the last one firing at 2 seconds instead of 3. Somehow this affects the behavior of the other timeouts.
Even setting one timeout to >= 3 seconds, the timeout will fail by itself. The number of timeouts set doesn't appear to affect this.
Tested with mbed-os-5.10.3, GCC_ARM v 6 q2, XDOT_L151CC, MTS_MDOT_F411RE, NUCLEO_F411RE.
Issue request type
[ ] Question
[ ] Enhancement
[x] Bug