我正在尝试编程STM32f10xx
MCU
并尝试设置时钟。在参考手册中写到,PLL
当打开时,硬件会设置一个标志,表示它已经准备好,或者LOCKED
,标志位被调用PLLRDY
。由PLLRDY
硬件设置为:
1 when the PLL is locked
0 when the PLL is not locked (NOT READY)
CR 寄存器或控制寄存器的复位值是ZERO
默认值。和RCC_CR_PLLRDY = 0x02000000
我需要放一个while循环来检查是否PLL
准备好,我的实现是否正确?
// Turn On PLL
RCC->CR |= RCC_CR_PLLON;
// Wait while the PLL "Phase LOCKED LOOP" is Locked and stable:
// Which is going to be set? the CR itself or the PLLRDY register?
while( !(RCC->CR & RCC_CR_PLLRDY) )
{
// Error when a certain time passes and the PLL is not ready!
}
或者应该是
while( !(RCC->CR | RCC_CR_PLLRDY) )
{
//SOME CODE!
}