【发布时间】:2021-03-11 17:05:16
【问题描述】:
我正在尝试编写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!
}
【问题讨论】: