summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2020-12-03 19:46:07 +0200
committerDamien George <damien@micropython.org>2020-12-07 17:00:56 +1100
commit7dc2f4ed384f45eb943e0b7dc39a539af7058b80 (patch)
tree912a78da2eacc23b9794bc1f8ad2e2445fbe827d
parent7b9b6d080a2d7de6db73fe4caaca29f54a1d716d (diff)
stm32/powerctrl: Ensure SysTick is disabled on STOP mode entry for H7.
Even though IRQs are disabled this seems to be required on H7 Rev Y, otherwise Systick interrupt triggers and the MCU leaves the stop mode immediately.
-rw-r--r--ports/stm32/powerctrl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ports/stm32/powerctrl.c b/ports/stm32/powerctrl.c
index 076215ba9..bf8be647f 100644
--- a/ports/stm32/powerctrl.c
+++ b/ports/stm32/powerctrl.c
@@ -502,6 +502,13 @@ void powerctrl_enter_stop_mode(void) {
// executed until after the clocks are reconfigured
uint32_t irq_state = disable_irq();
+ #if defined(STM32H7)
+ // Disable SysTick Interrupt
+ // Note: This seems to be required at least on the H7 REV Y,
+ // otherwise the MCU will leave stop mode immediately on entry.
+ SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
+ #endif
+
#if defined(MICROPY_BOARD_ENTER_STOP)
MICROPY_BOARD_ENTER_STOP
#endif
@@ -659,6 +666,11 @@ void powerctrl_enter_stop_mode(void) {
MICROPY_BOARD_LEAVE_STOP
#endif
+ #if defined(STM32H7)
+ // Enable SysTick Interrupt
+ SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
+ #endif
+
// Enable IRQs now that all clocks are reconfigured
enable_irq(irq_state);
}