Skip to content

Instantly share code, notes, and snippets.

@csrohit
Last active January 9, 2023 17:23
Show Gist options
  • Save csrohit/f63ca5034f1960d0e49302959df65526 to your computer and use it in GitHub Desktop.
Save csrohit/f63ca5034f1960d0e49302959df65526 to your computer and use it in GitHub Desktop.
Supporting gist for clock configuration article
RCC->CFGR |= RCC_CFGR_PPRE1_2;
RCC->CFGR |= RCC_CFGR_PLLXTPRE_HSE;
RCC->CFGR |= RCC_CFGR_SW_PLL;
while (!(RCC->CFGR & RCC_CFGR_SWS_PLL))
;
// clock is ready @72MHZ
RCC->CR |= RCC_CR_HSEON;
while (!(RCC->CR & RCC_CR_HSERDY))
;
// hse ready
FLASH->ACR |= FLASH_ACR_LATENCY_2;
RCC->CFGR |= RCC_CFGR_PLLSRC;
RCC->CFGR |= RCC_CFGR_PLLMULL9;
RCC->CR |= RCC_CR_PLLON;
while (!(RCC->CR & RCC_CR_PLLRDY))
;
// PLL is ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment