77 #include "stm32f0xx.h"
110 __I uint8_t
AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
139 RCC->CR |= (uint32_t)0x00000001;
141 #if defined(STM32F051)
143 RCC->CFGR &= (uint32_t)0xF8FFB80C;
146 RCC->CFGR &= (uint32_t)0x08FFB80C;
150 RCC->CR &= (uint32_t)0xFEF6FFFF;
153 RCC->CR &= (uint32_t)0xFFFBFFFF;
156 RCC->CFGR &= (uint32_t)0xFFC0FFFF;
159 RCC->CFGR2 &= (uint32_t)0xFFFFFFF0;
162 RCC->CFGR3 &= (uint32_t)0xFFFFFEAC;
165 RCC->CR2 &= (uint32_t)0xFFFFFFFE;
168 RCC->CIR = 0x00000000;
210 uint32_t tmp = 0, pllmull = 0, pllsource = 0, prediv1factor = 0;
213 tmp = RCC->CFGR & RCC_CFGR_SWS;
225 pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
226 pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
227 pllmull = ( pllmull >> 18) + 2;
229 if (pllsource == 0x00)
236 prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
261 __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
269 RCC->CR |= ((uint32_t)RCC_CR_HSEON);
274 HSEStatus = RCC->CR & RCC_CR_HSERDY;
276 }
while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
278 if ((RCC->CR & RCC_CR_HSERDY) != RESET)
280 HSEStatus = (uint32_t)0x01;
284 HSEStatus = (uint32_t)0x00;
287 if (HSEStatus == (uint32_t)0x01)
290 FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
293 RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
296 RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE_DIV1;
299 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
300 RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL5);
303 RCC->CR |= RCC_CR_PLLON;
306 while((RCC->CR & RCC_CR_PLLRDY) == 0)
311 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
312 RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
315 while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL)
void SystemCoreClockUpdate(void)
Update SystemCoreClock according to Clock Register Values The SystemCoreClock variable contains the c...
__I uint8_t AHBPrescTable[16]
void SystemInit(void)
Setup the microcontroller system. Initialize the Embedded Flash Interface, the PLL and update the Sys...
static void SetSysClock(void)
Configures the System clock frequency, AHB/APBx prescalers and Flash settings.