Marijn Stam <marijnstam@...>
I'm using the Zephyr RTOS on a STM32F091 and have recently started working on implementing some low-power states (sleep and STOP). The system is fed by the PLL (48MHz) which is in turn fed by a HSE (20MHz).
I'm using the RTC peripheral to manage wake-ups, I simply set ALARMA at ~500ms before going to sleep.
What I see after waking up from STOP mode, is a bunch of garbage characters on the UART output and the whole system seemed to have slowed down significantly. A blinking LED for example, is now blinking much slower.
This is the code I use to enter the STOP mode (in functions pm_power_state_set and pm_power_state_exit_post_ops):
Note that this is not a Zephyr power driver, since the F091 was not supported yet. It is, however, heavily influenced by the other available power driver for STM32 platform (G0/L0 for example)
Then this is called whenever the STOP mode is exited:
The stm32_clock_control_init(NULL) does the following in sequence:
To verify, I routed the SYSCLK to MCO, so I can monitor it on a scope. It shows the correct clock speed of 48MHz before entering the low-power procedure, then it is 8MHz after exiting STOP mode (HSI is startup clock).
After the stm32_clock_control_init(NULL) function has been executed, the SYSCLK is back at 48MHz, and the RCC registers show the right configuration.
Then, very shortly after, the RCC configuration is reset back to exit STOP conditions, i.e. HSI on, HSE and PLL off, HSI as system clock, back at 8MHz. This seems to happen asynchronously and I can't pinpoint why it happens.
This does not happen when I enter/exit sleep mode, only STOP.
I've verified that the Clock Security System is off.
Any help with this would be greatly appreciated, as I am grasping at straws at this point.
Thank you kindly,