diff --git a/platform/source/SysTimer.cpp b/platform/source/SysTimer.cpp index 0803849e25d..6ebfbf053ea 100644 --- a/platform/source/SysTimer.cpp +++ b/platform/source/SysTimer.cpp @@ -192,10 +192,15 @@ void SysTimer::acknowledge_tick() { // Try to avoid missed ticks if OS's IRQ level is not keeping // up with our handler. - // 8-bit counter to save space, and also make sure it we don't - // try TOO hard to resync if something goes really awry - - // resync will reset if the count hits 256. - if (core_util_atomic_decr_u8(&_unacknowledged_ticks, 1) > 0) { + // This value should not get large during normal operation. + // However, when interrupts are not handled for a while + // (e.g. by debug halt or large critical sections) this + // number will get large very quickly. All these un- + // acknowledged ticks need to be processed because otherwise + // the OS timing will be off. Processing may take a while. + // For more info see: https://github.com/ARMmbed/mbed-os/issues/13801 + + if (core_util_atomic_decr_u32(&_unacknowledged_ticks, 1) > 0) { _set_irq_pending(); } } diff --git a/platform/source/SysTimer.h b/platform/source/SysTimer.h index 3098a8e6142..73285a4ffdd 100644 --- a/platform/source/SysTimer.h +++ b/platform/source/SysTimer.h @@ -172,7 +172,7 @@ class SysTimer: private mbed::TimerEvent, private mbed::NonCopyable