Skip to content

Commit 0d8d911

Browse files
pi-chmdpgeorge
authored andcommitted
stm32/powerctrl: Disable sys tick interrupt in stop mode on some STM32s.
According to ST Errata ES0206 Rev 18, Section 2.2.1, on STM32F427x, STM32F437x, STM32F429x and STM32F439x. If the system tick interrupt is enabled during stop mode while certain bits are set in the DBGMCU_CR, then the system will immediately wake from stop mode. Suggested workaround is to disable system tick timer interrupt when entering stop mode. According to ST Errate ES0394 Rev 11, Section 2.2.17, on STM32WB55Cx and STM32WB35Cx. If the system tick interrupt is enabled during stop 0, stop 1 or stop 2 while certain bits are set in DBGMCU_CR, then system will immediately wake from stop mode but the system remains in low power state. The CPU therefore fetches incorrect data from inactive Flash, which can cause a hard fault. Suggested workaround is to disable system tick timer interrupt when entering stop mode.
1 parent 14105ff commit 0d8d911

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ports/stm32/powerctrl.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,17 @@ void powerctrl_enter_stop_mode(void) {
685685
// executed until after the clocks are reconfigured
686686
uint32_t irq_state = disable_irq();
687687

688-
#if defined(STM32H7)
688+
#if defined(STM32H7) || \
689+
defined(STM32F427xx) || defined(STM32F437xx) || \
690+
defined(STM32F429xx) || defined(STM32F439xx) || \
691+
defined(STM32WB55xx) || defined(STM32WB35xx)
689692
// Disable SysTick Interrupt
690693
// Note: This seems to be required at least on the H7 REV Y,
691694
// otherwise the MCU will leave stop mode immediately on entry.
695+
// Note: According to ST Errata ES0206 Rev 18, Section 2.2.1 this is needed
696+
// for STM32F427xx, STM32F437xx, STM32F429xx and STM32F439xx
697+
// Note: According to ST Errata ES0394 Rev 11, Section 2.2.17 this is needed
698+
// for STM32WB55xx and STM32WB35xx
692699
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
693700
#endif
694701

@@ -849,7 +856,10 @@ void powerctrl_enter_stop_mode(void) {
849856
MICROPY_BOARD_LEAVE_STOP
850857
#endif
851858

852-
#if defined(STM32H7)
859+
#if defined(STM32H7) || \
860+
defined(STM32F427xx) || defined(STM32F437xx) || \
861+
defined(STM32F429xx) || defined(STM32F439xx) || \
862+
defined(STM32WB55xx) || defined(STM32WB35xx)
853863
// Enable SysTick Interrupt
854864
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
855865
#endif

0 commit comments

Comments
 (0)