Skip to content

Commit

Permalink
stm32: USB clock source from PLLQCLK on stm32g0 (#5341)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
  • Loading branch information
bigtreetech committed Mar 9, 2022
1 parent c721c20 commit d75154d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/stm32/stm32g0.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ clock_setup(void)
}
pllcfgr |= (pll_freq/pll_base) << RCC_PLLCFGR_PLLN_Pos;
pllcfgr |= (pll_freq/CONFIG_CLOCK_FREQ - 1) << RCC_PLLCFGR_PLLR_Pos;
RCC->PLLCFGR = pllcfgr | RCC_PLLCFGR_PLLREN;
pllcfgr |= (pll_freq/FREQ_USB - 1) << RCC_PLLCFGR_PLLQ_Pos;
RCC->PLLCFGR = pllcfgr | RCC_PLLCFGR_PLLREN | RCC_PLLCFGR_PLLQEN;
RCC->CR |= RCC_CR_PLLON;

// Wait for PLL lock
Expand All @@ -95,11 +96,8 @@ clock_setup(void)

// Enable USB clock
if (CONFIG_USBSERIAL) {
RCC->CR |= RCC_CR_HSI48ON;
while (!(RCC->CR & RCC_CR_HSI48RDY))
;
enable_pclock(CRS_BASE);
CRS->CR |= CRS_CR_AUTOTRIMEN | CRS_CR_CEN;
// PLLQCLK
RCC->CCIPR2 |= RCC_CCIPR2_USBSEL_1;
}
}

Expand Down

0 comments on commit d75154d

Please sign in to comment.