105 #include "stm32f30x.h"
125 #define VECT_TAB_OFFSET 0x0
143 uint32_t SystemCoreClock = 72000000;
145 __I uint8_t
AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
174 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
175 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));
180 RCC->CR |= (uint32_t)0x00000001;
183 RCC->CFGR &= 0xF87FC00C;
186 RCC->CR &= (uint32_t)0xFEF6FFFF;
189 RCC->CR &= (uint32_t)0xFFFBFFFF;
192 RCC->CFGR &= (uint32_t)0xFF80FFFF;
195 RCC->CFGR2 &= (uint32_t)0xFFFFFFF0;
198 RCC->CFGR3 &= (uint32_t)0xFF00FCCC;
201 RCC->CIR = 0x00000000;
251 uint32_t tmp = 0, pllmull = 0, pllsource = 0, prediv1factor = 0;
254 tmp = RCC->CFGR & RCC_CFGR_SWS;
266 pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
267 pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
268 pllmull = ( pllmull >> 18) + 2;
270 if (pllsource == 0x00)
277 prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
302 __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
310 RCC->CR |= ((uint32_t)RCC_CR_HSEON);
315 HSEStatus = RCC->CR & RCC_CR_HSERDY;
317 }
while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
319 if ((RCC->CR & RCC_CR_HSERDY) != RESET)
321 HSEStatus = (uint32_t)0x01;
325 HSEStatus = (uint32_t)0x00;
328 if (HSEStatus == (uint32_t)0x01)
331 FLASH->ACR = FLASH_ACR_PRFTBE | (uint32_t)FLASH_ACR_LATENCY_1;
334 RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
337 RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
340 RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
343 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
344 RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL9);
347 RCC->CR |= RCC_CR_PLLON;
350 while((RCC->CR & RCC_CR_PLLRDY) == 0)
355 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
356 RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
359 while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL)
void SystemCoreClockUpdate(void)
Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable cont...
void SystemInit(void)
Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the Syst...
__I uint8_t AHBPrescTable[16]
static void SetSysClock(void)
Configures the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers and Flash...