Repository navigation
fix: suspend SysTick in LowPower_stop() - #137
Merged
Merged
Conversation
Like LowPower_sleep(), suspend the tick before entering Stop mode. With DBGMCU DBG_STOP set, the core clock and SysTick keep running in Stop mode and the pending tick interrupt wakes WFI despite PRIMASK, so deepSleep() returned almost immediately. The tick is enabled again on wake-up by SystemClock_ConfigFromStop() (HAL_RCC_ClockConfig() -> HAL_InitTick()), before the existing HAL_Delay(10). Fixes stm32duino#135 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fpistm
approved these changes
Nov 7, 2026
Member
|
Thanks for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Suspend the SysTick interrupt in
LowPower_stop(), asLowPower_sleep()already does.This PR fixes/implements the following bugs/features
LowPower.deepSleep()returns almost immediately when DBGMCUDBG_STOPis set (deepSleep() returns immediately when DBGMCU DBG_STOP is set: LowPower_stop() doesn't suspend SysTick #135)Motivation
With
DBG_STOPset, the core clock keeps running in Stop mode (on STM32L0 per RM0367, DBGMCU_CR), so SysTick keeps counting and its pending interrupt endsWFIeven with PRIMASK set.deepSleep(2000)then returns about 40 times per second.DBG_STOPsurvives every reset except power-on, so once set by debug code or a debug session, deep sleep stays broken until a power cycle. This isn't specific to STM32F1: any series whereDBG_STOPkeeps the core clock running in Stop is affected. WhenDBG_STOPis clear, suspending the tick changes nothing.No explicit
HAL_ResumeTick()is added: on wake-upSystemClock_ConfigFromStop()reconfigures the clocks throughHAL_RCC_ClockConfig(), which callsHAL_InitTick()and re-enables the SysTick interrupt before the existingHAL_Delay(10).The same change was proposed in #102 (closed unmerged by its author) for a related debug case (RTC frozen during debug).
Validation
Tested on an AcSiP S76S (STM32L073RZ, variant
ACSIP_S76S) with the repro sketch from #135:DBG_STOPsetDBG_STOPcleardeepSleep(2000)returns ~40 times/sCode formatting
Checked locally with AStyle 3.6.12 and
extras/.astylerc: no changes.Closing issues
Fixes #135
🤖 Generated with Claude Code