Change system clock stm32f0 manual
I want to change system clock as a PLL(using HSE) 20 Minute after systemInit. thats why I must change it in main function not system_stm32f0.c file.
Here is my code, Not working properly. I dint do anything interrupt function.
void ClockInit(void)
{
if ((RCC->CFGR & RCC_CFGR_SWS) == RCC_CFGR_SWS_PLL)
{
RCC->CFGR &= (uint32_t) (~RCC_CFGR_SW);
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI) {}
}
RCC->CR &= (uint32_t)(~RCC_CR_PLLON);
while((RCC->CR & RCC_CR_PLLRDY) != 0) {}
RCC->CFGR &= ~(RCC_CFGR_PLLMULL | RCC_CFGR_PLLSRC);
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSI_Div2 | RCC_CFGR_PLLMUL5);
//RCC_PLLConfig(RCC_CFGR_PLLSRC_HSI_Div2,RCC_CFGR_PLLMUL5);
RCC->CR |= RCC_CR_PLLON; /* (7) */
while((RCC->CR & RCC_CR_PLLRDY) == 0) {}
RCC->CFGR |= (uint32_t) (RCC_CFGR_SW_PLL);
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL) {}
SystemCoreClockUpdate();
}
Thanks for everything
