From 892594adbccf45b198fc067ea994048c76523936 Mon Sep 17 00:00:00 2001 From: sslupsky Date: Tue, 14 May 2019 01:56:55 -0600 Subject: [PATCH] Fix SysTick timer lockup when waking from sleep (#17) * fix SysTick timer lockup when waking from sleep --- src/samd/ArduinoLowPower.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/samd/ArduinoLowPower.cpp b/src/samd/ArduinoLowPower.cpp index d756ed6..faee7e8 100644 --- a/src/samd/ArduinoLowPower.cpp +++ b/src/samd/ArduinoLowPower.cpp @@ -23,9 +23,13 @@ void ArduinoLowPowerClass::sleep() { USBDevice.detach(); restoreUSBDevice = true; } + // Disable systick interrupt: See https://www.avrfreaks.net/forum/samd21-samd21e16b-sporadically-locks-and-does-not-wake-standby-sleep-mode + SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; __DSB(); __WFI(); + // Enable systick interrupt + SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; if (restoreUSBDevice) { USBDevice.attach(); }