zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.61k stars 6.5k forks source link

Change SYSCLK on stm32l4 at runtime. #47968

Open jorbo opened 2 years ago

jorbo commented 2 years ago

Is your enhancement proposal related to a problem? Please describe. There does not seem to be a way to change the system clock at runtime. I would like to be able to, for example, switch from the MSI at one frequency clock to the HSI clock at another frequency. I know the clock_control.h allows you to do this to specific subsystems but it does not seem possible to do with the system clock.

Describe the solution you'd like Maybe an optional clock_control.h api function that can manipulate the system clock.

Describe alternatives you've considered I could use ST's HAL or LL libraries to do it but I'm hoping there's a zephyr way.

Additional context I made a discussion post here https://github.com/zephyrproject-rtos/zephyr/discussions/47876 with some more specifics but wasn't sure if I should make this an issue or not.

erwango commented 2 years ago

@jorbo Changing the clock frequency at run time is not supported yet on Zephyr globally from what I know. From what I can tell at least on STM32 clock control driver this would required significant changes (to reach an acceptable level of support in upstream, ie through most series and drivers). Currently there are no plans to support such feature, so I'd suggest to make your way using Cube API for now.

(I'm removing the STM32 tag, as this topic is not platform specific).