Question
Set PLL as the system clock for STM32F401RE board
Here i am trying to set PLL as the system clock using HSI of 16MHz for STM32F401RE development board, but the moment i enable the "SET PLL as system clock" bit, the system gets reset. What can be the reason for this. I am trying to achieve 70 MHz of frequency.
Below is the code for the same.
int main()
{
// Clear the default 192 setting
RCC->PLLCFGR &= ~(192 << 6);
// Set 200 to PLLN
RCC->PLLCFGR |= (216 << 6);
// Clear the default 16 setting
RCC->PLLCFGR &= ~(16 << 0);
// Set 8 to PLLM
RCC->PLLCFGR |= (8 << 0);
// Set PLLP to 6
RCC->PLLCFGR |= (2 << 16);
// Turn on PLL from RCC CR Register
RCC->CR |= (1 << 24);
// SET PLL as system clock
RCC->CFGR |= (2 << 0);
// Wait while the status flag is set
while(!(RCC->CFGR >> 2 & 2));
while(1)
{
}
}
