From 9be2421890be71ff7cfbda497851d78ba83c3614 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 20 Mar 2023 12:07:57 +0100 Subject: [PATCH] cpu/gd32v: allow reconfig PLL multiplier in clock config To be able to reconfigure the PLL multiplier in clock configuration, the existing value has to be reset first. This becomes necessary when changing the core clock, e.g. when booting with riotboot an application that uses USB. --- cpu/gd32v/clock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/gd32v/clock.c b/cpu/gd32v/clock.c index a51d04f443..a87d493df8 100644 --- a/cpu/gd32v/clock.c +++ b/cpu/gd32v/clock.c @@ -125,6 +125,9 @@ void gd32vf103_clock_init(void) RCU->CTL &= (RCU_CTL_IRC8MCALIB_Msk | RCU_CTL_IRC8MADJ_Msk); RCU->CTL |= RCU_CTL_IRC8MEN_Msk; + /* reset PLL multiplier, required when configured before, e.g. in riotboot */ + RCU->CFG0 &= ~(RCU_CFG0_PLLMF_3_0_Msk | RCU_CFG0_PLLMF_4_Msk); + if (IS_ACTIVE(CONFIG_BOARD_HAS_HXTAL)) { /* if the board has an HXTAL, HXTAL is used as PLL input and PREDEV0 is set */ cpu_reg_enable_bits(&RCU->CTL, RCU_CTL_HXTALEN_Msk);