aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/powerctrl.c
AgeCommit message (Collapse)Author
2021-04-07stm32/powerctrl: Support using PLLI2C on STM32F413 as USB clock source.Damien George
So SYSCLK can run at more varied frequencies, eg 100MHz. Signed-off-by: Damien George <damien@micropython.org>
2021-04-07stm32/powerctrl: Allow a board to configure AHB and APB clock dividers.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-03-11stm32/powerctrl: Save and restore EWUP state when configuring standby.Peter Hinch
This allows the user to enable wake-up sources using the EWUP bits, on F7 MCUs. Disabling the wake-up sources while clearing the wake-up flags follows the reference manual and ST examples.
2020-12-07stm32/powerctrl: Ensure SysTick is disabled on STOP mode entry for H7.iabdalkader
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.
2020-12-07stm32/powerctrl: Set H7 RTC wakeup flags.iabdalkader
2020-12-07stm32/powerctrl: Disable RTC write protection before changing flags.iabdalkader
2020-12-07stm32/powerctrl: On H7, re-enable disabled OSCs/PLLs on exit from STOP.iabdalkader
This commit saves OSCs/PLLs state before STOP mode and restores them on exit. Some boards use HSI48 for USB for example, others have PLL2/3 enabled, etc.
2020-12-07stm32/powerctrl: Fix STOP mode voltage scaling on H7 REV V devices.iabdalkader
2020-12-07stm32/powerctrl: Define RCC_SR_SFTRSTF flag for H747.iabdalkader
2020-06-02stm32/modmachine: Allow changing AHB and APB bus frequencies on STM32WB.Damien George
For now SYSCLK cannot be changed and must remain at 64MHz.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-01-31stm32/powerctrl: Reenable PLL3 on H7 MCUs when waking from stop mode.Damien George
So that USB can work.
2020-01-31stm32/powerctrl: Improve support for changing system freq on H7 MCUs.Damien George
This commit improves pllvalues.py to generate PLL values for H7 MCUs that are valid (VCO in and out are in range) and extend for the entire range of SYSCLK values up to 400MHz (up to 480MHz is currently unsupported).
2020-01-30stm32/powerctrl: Enable overdrive on F7 when waking from stop mode.Damien George
Because if the SYSCLK is set to 180MHz or higher it will require this to be on already.
2020-01-30stm32/powerctrl: Disable HSI if not needed to save a bit of power.Damien George
2020-01-29stm32/powerctrl: For F7, allow PLLM!=HSE when setting PLLSAI to 48MHz.Damien George
PLLM is shared among all PLL blocks on F7 MCUs, and this calculation to configure PLLSAI to have 48MHz on the P output previously assumed that PLLM is equal to HSE (eg PLLM=25 for HSE=25MHz). This commit relaxes this assumption to allow other values of PLLM.
2019-09-04stm32/powerctrl: Fix machine.bootloader() for L0 MCUs.Jim Mussared
2019-07-17stm32: Add initial support for STM32WBxx MCUs.Damien George
This new series of MCUs is similar to the L4 series with an additional Cortex-M0 coprocessor. The firmware for the wireless stack must be managed separately and MicroPython does not currently interface to it. Supported features so far include: RTC, UART, USB, internal flash filesystem.
2019-07-08stm32/powerctrl: Move L0's SystemClock_Config to powerctrlboot.c file.Damien George
2019-07-05stm32: Add initial support for STM32L0xx MCUs.Damien George
2019-07-03stm32/powerctrl: Add hooks for a board to perform actions on sleep/wake.Damien George
2019-06-25stm32: Enter bootloader via a system reset.Damien George
Entering a bootloader (ST system bootloader, or custom mboot) from software by directly branching to it is not reliable, and the reliability of it working can depend on the peripherals that were enabled by the application code. It's also not possible to branch to a bootloader if the WDT is enabled (unless the bootloader has specific provisions to feed the WDT). This patch changes the way a bootloader is entered from software by first doing a complete system reset, then branching to the desired bootloader early on in the start-up process. The top two words of RAM (of the stack) are reserved to store flags indicating that the bootloader should be entered after a reset.
2019-05-02stm32/powerctrl: Support changing frequency when HSI is clock source.Damien George
This patch makes pllvalues.py generate two tables: one for when HSI is used and one for when HSE is used. The correct table is then selected at compile time via the existing MICROPY_HW_CLK_USE_HSI.
2019-04-29stm32/powerctrl: Deselect PLLSAI as 48MHz src before turning off PLLSAI.Damien George
On the STM32F722 (at least, but STM32F767 is not affected) the CK48MSEL bit must be deselected before PLLSAION is turned off, or else the 48MHz peripherals (RNG, SDMMC, USB) may get stuck without a clock source. In such "lock up" cases it seems that these peripherals are still being clocked from the PLLSAI even though the CK48MSEL bit is turned off. A hard reset does not get them out of this stuck state. Enabling the PLLSAI and then disabling it does get them out. A test case to see this is: import machine, pyb for i in range(100): machine.freq(122_000000) machine.freq(120_000000) print(i, [pyb.rng() for _ in range(4)]) On occasion the RNG will just return 0's, but will get fixed again on the next loop (when PLLSAI is enabled by the change to a SYSCLK of 122MHz). Fixes issue #4696.
2019-04-18stm32/powerctrl: Enable EIWUP to ensure RTC wakes device from standby.Damien George
2019-03-05stm32: Add compile-time option to use HSI as clock source.Francisco J. Manno
To use HSI instead of HSE define MICROPY_HW_CLK_USE_HSI as 1 in the board configuration file. The default is to use HSE. HSI has been made the default for the NUCLEO_F401RE board to serve as an example, and because early revisions of this board need a hardware modification to get HSE working.
2018-12-05stm32/powerctrl: Add support for standby mode on L4 MCUs.Damien George
This maps to machine.deepsleep() which is now supported.
2018-11-28stm32/powerctrl: Disable IRQs during stop mode to allow reconfig on wakeDamien George
2018-11-28stm32/powerctrl: Move (deep)sleep funcs from modmachine.c to powerctrl.cDamien George
2018-09-24stm32/powerctrl: Don't configure clocks if already at desired frequency.Damien George
Configuring clocks is a critical operation and is best to avoid when possible. If the clocks really need to be reset to the same values then one can pass in a slightly higher value, eg 168000001 Hz to get 168MHz.
2018-09-24stm32/powerctrl: Optimise passing of default values to set_sysclk.Damien George
2018-09-24stm32/powerctrl: Factor code that configures PLLSAI on F7 MCUs.Damien George
2018-09-24stm32/powerctrl: Factor code to set RCC PLL and use it in startup.Damien George
This ensures that on first boot the most optimal settings are used for the voltage scaling and flash latency (for F7 MCUs). This commit also provides more fine-grained control for the flash latency settings.
2018-09-24stm32/powerctrl: Fix configuring APB1/APB2 frequency when AHB also set.Damien George
APB1/APB2 are derived from AHB, so if the user sets AHB!=SYSCLK then the APB1/APB2 dividers must be computed from the new AHB.
2018-09-24stm32/powerctrl: Move function to set SYSCLK into new powerctrl file.Damien George
Power and clock control is low-level functionality and it makes sense to have it in a dedicated file, at least so it can be reused by other parts of the code.