Skip to content

Commit

Permalink
stm32/modmachine: Re-enable PLLSAI[1] after waking from stop mode.
Browse files Browse the repository at this point in the history
On F7s PLLSAI is used as a 48MHz clock source if the main PLL cannot
provide such a frequency, and on L4s PLLSAI1 is always used as a clock
source for the peripherals.  This commit makes sure these PLLs are
re-enabled upon waking from stop mode so the peripherals work.

See issues #4022 and #4178 (L4 specific).
  • Loading branch information
dpgeorge committed Sep 24, 2018
1 parent 4df1943 commit 1acf58c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ports/stm32/modmachine.c
Expand Up @@ -568,6 +568,22 @@ STATIC mp_obj_t machine_sleep(void) {
#endif
}

#if defined(STM32F7)
if (RCC->DCKCFGR2 & RCC_DCKCFGR2_CK48MSEL) {
// Enable PLLSAI if it is selected as 48MHz source
RCC->CR |= RCC_CR_PLLSAION;
while (!(RCC->CR & RCC_CR_PLLSAIRDY)) {
}
}
#endif

#if defined(STM32L4)
// Enable PLLSAI1 for peripherals that use it
RCC->CR |= RCC_CR_PLLSAI1ON;
while (!(RCC->CR & RCC_CR_PLLSAI1RDY)) {
}
#endif

#endif

return mp_const_none;
Expand Down

0 comments on commit 1acf58c

Please sign in to comment.