大家好: 现有一项目,其中为了节能要每隔大概200ms让lpc2132掉电一次(1s后由RTC唤醒),程序运行的时候设置的cpu工作频率是Fcclk=48mhz,Pclk=Pcclk,所以醒来后不能用lpc2132默认的配置,要重新连接pll,我是在醒来后调用了一个重设置pll的函数void Pll_ReConnect(void),其内容是从target.c中拷贝过来的,如下所示,但是系统运行大概经过几十次掉电、醒来后就会死在等待连接成功的地方“while((PLLSTAT & (1 << 10)) == 0);” 以下是该函数的内容和config.h中的设置: void Pll_ReConnect(void) { PLLCON = 1; #if (Fpclk / (Fcclk / 4)) == 1 VPBDIV = 0; #endif #if (Fpclk / (Fcclk / 4)) == 2 VPBDIV = 2; #endif #if (Fpclk / (Fcclk / 4)) == 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; while((PLLSTAT & (1 << 10)) == 0); PLLCON = 3; PLLFEED = 0xaa; PLLFEED = 0x55; }
#define Fosc 12000000 //Crystal frequence,10MHz~25MHz,should be the same as actual status. //应当与实际一至晶振频率,10MHz~25MHz,应当与实际一至 #define Fcclk (Fosc * 4) //System frequence,should be (1~32)multiples of Fosc,and should be equal or less than 60MHz. //系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ #define Fcco (Fcclk * 4) //CCO frequence,should be 2、4、8、16 multiples of Fcclk, ranged from 156MHz to 320MHz. //CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz #define Fpclk (Fcclk / 4) * 4 //VPB clock frequence , must be 1、2、4 multiples of (Fcclk / 4). //VPB时钟频率,只能为(Fcclk / 4)的1、2、4倍
#include "target.h" //This line may not be deleted 这一句不能删除
#endif
是不是这个pll不能如此频繁的重设置?请各位指教!谢谢 |