Skip to content

Commit

Permalink
stm32/powerctrl: Ensure SysTick is disabled on STOP mode entry for H7.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iabdalkader authored and dpgeorge committed Dec 7, 2020
1 parent 7b9b6d0 commit 7dc2f4e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ports/stm32/powerctrl.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 7dc2f4e

Please sign in to comment.