这是第一种:..............................................................................
void PLL_Init(void)
{
/* 设置系统各部分时钟 */
PLLCON = 1;
#if ((Fcclk / 4) / Fpclk) == 1
VPBDIV = 0;
#endif
#if ((Fcclk / 4) / Fpclk) == 2
VPBDIV = 2;
#endif
#if ((Fcclk / 4) / Fpclk) == 4
VPBDIV = 1;
#endif
#if (Fcco / Fcclk) == 2
PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
PLLFEED = 0xaa;
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0);
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
}
这是第二种。......................................................................................
PLL_INIT()
{
PLLCON = 1; // 使能PLL
PLLCFG = 0x25; // 设置M 为6,P为2
PLLFEED = 0xAA; // 发送PLL馈送序列
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0); // 等待PLL锁定
PLLCON = 3; // PLL 使能和锁定
PLLFEED = 0xAA; // 发送PLL馈送序列
PLLFEED = 0x55;
}
这2种方式初始化的效果都一样的吗? 小弟我刚学,不懂,谢谢! |