How to re-configure the system clock by code in runtime?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

leon_titan
Posts: 24
Joined: Sun Jan 12, 2020 2:11 pm
Has thanked: 4 times

How to re-configure the system clock by code in runtime?

Postby leon_titan » Wed Jul 27, 2022 9:23 am

Is there any way to re-configure or change the system clock by code in runtime?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: How to re-configure the system clock by code in runtime?

Postby Giovanni » Wed Jul 27, 2022 2:41 pm

Hi,

Only for some newest devices: G0, G4, L4+, WL. The procedure is quite complex and requires stopping and restarting all drivers affected by the clock change.

Giovanni

leon_titan
Posts: 24
Joined: Sun Jan 12, 2020 2:11 pm
Has thanked: 4 times

Re: How to re-configure the system clock by code in runtime?

Postby leon_titan » Thu Jul 28, 2022 12:00 pm

1. my board is stm32l4xx,can i use the stm32L4+'s code?
2. the clock is setuped in halInit() or chSysInit()? can i call that in runtime to re-configure the clock?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: How to re-configure the system clock by code in runtime?

Postby Giovanni » Thu Jul 28, 2022 12:15 pm

Hi,

On the L4 there is no support for dynamic clocking, L4+ is quite different and the code cannot be used.

It would be possible to do in L4 HAL the same changes done in L4+ HAL but I have no immediate plans for that, you may try to compare hal_lld.c and hal_lld.h.

Giovanni

leon_titan
Posts: 24
Joined: Sun Jan 12, 2020 2:11 pm
Has thanked: 4 times

Re: How to re-configure the system clock by code in runtime?

Postby leon_titan » Thu Jul 28, 2022 1:02 pm

OK, thx for reply, will try that.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 15 guests