用的LPC2220的CPU,OSC为11.0592MHz,用的ZLG实例中的时钟设置,如下:
//时钟定义 #define Fosc 11059200 #define Fcclk (Fosc * 4) #define Fcco (Fcclk * 4) #define Fpclk (Fcclk / 4) * 1
//时钟设置流程 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;
写了一个延时函数如下,实验下来该函数执行80000次约是1秒,约每执行一次12.5微秒,重复执行的就5条指令,执行一次怎么会这么长时间? while(--i) { asm("CMP R1,#0"); }
该延时函数反汇编如下:
|