测试了一下,用IO口输出方波,用示波器测最大只能是3.9M,大家帮看看是不是程序有问题,谢谢了,晶振用的是 11.0592M 的,板子就是ZLG的EasyARM 2131
#include "config.h"
#define BO_OUT (1<<5) //P0.5脚输出
int main (void) {// add user source code PLLCON = 1; //设置PLL PLLCFG = 0x25; //M=5,P=2(试过M=4,P=2,更慢) PLLFEED = 0xAA; PLLFEED = 0x55; while((PLLSTAT & (1<<10))==0); PLLCON = 3; PLLFEED = 0xAA; PLLFEED = 0x55; VPBDIV = (VPBDIV&0xfc)|0x01; //VPB分频,设为和处理器时钟相同
PINSEL0 = PINSEL0&(~(0x03<<2)); IO0DIR = IO0DIR|BO_OUT; //设置IO脚方向,输出 IO1DIR = IO1DIR|(0x03<<19); //点亮两个LED,指示用 IO1CLR = 0x03<<19; while(1) { IO0SET = BO_OUT; //交替清零和置一,产生方波 IO0CLR = BO_OUT; } return 0; } |