最近使用NUC505板子,发现在系统时钟初始化中有这样一个函数,却不明白是什么意思,请各位大神指教下
static uint32_t PLL_calculate(uint32_t u32Target)
{
uint32_t u32M, u32N, u32P;
uint32_t u32Fpll_clko;
uint32_t u32Fvco;
uint32_t u32Register, u32Fin=__HXT/1000;
do
{
#if 0 /* Much jitter */
for(u32M =1 ; u32M<=64; u32M=u32M+1){
for(u32N=1 ; u32N<=128; u32N=u32N+1){
for(u32P =1 ; u32P<=8; u32P=u32P+1){
#else /* Less jitter */
for(u32P =8 ; u32P>=1; u32P=u32P-1){
for(u32N=1 ; u32N<=128; u32N=u32N+1){
for(u32M =1 ; u32M<=64; u32M=u32M+1){
#endif
u32Fvco = u32Fin/u32M*u32N;
if((u32Fvco<300000))
continue;
if((u32Fvco>1000000))
continue;
if(pllfreq_pdf_check(u32N, u32M, u32Fin)<0)
continue;
u32Fpll_clko = (u32Fin/u32M)*u32N/u32P;
if( (u32Fpll_clko==u32Target) ){
u32Register = ((u32P-1)<<13) | ((u32M-1)<<7) | ((u32N-1));
return u32Register;
}
}
}
}
}while(0);
return 0;
} |