用这个官方库文件,使用内部IRC8M 时钟,是正确的,使用外部晶振是错的。
/* CK_PLL = (CK_PREDIV0) * 12 = 48 MHz */
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4 | RCU_CFG0_PLLMF_5);
RCU_CFG0 |= (RCU_PLLSRC_HXTAL_IRC48M | RCU_PLL_MUL12);
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
RCU_CFG1 &= ~(RCU_CFG1_PLLPRESEL | RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
//RCU_CFG1 |= (RCU_PLLPRESRC_HXTAL | RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
官方代码是按照外部晶振25M 计算的,我使用的是8M:
8M/2 进入PLL
RCU_CFG1 |= (RCU_PLLPRESRC_HXTAL | RCU_PLL1_MUL8 | RCU_PREDV1_DIV16 | RCU_PREDV0_DIV2);
结果是错的。有点奇怪了?有谁发现这个问题吗?
|