第一次接受LPC1114单片机,现用P0.8、P0.9输出两路PWM波,周期1000us,占空比比实际相差60-70us,代码如下,求指导
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7);
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);
LPC_IOCON->PIO0_8 &= ~0x07;
LPC_IOCON->PIO0_8 |= 0x02;
LPC_IOCON->PIO0_9 &= ~0x07;
LPC_IOCON->PIO0_9 |= 0x02;
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<16);
LPC_TMR16B0->TCR = 0x02;
LPC_TMR16B0->PR = SystemCoreClock/1000000-1; //1us
LPC_TMR16B0->PWMC= 0x03;
LPC_TMR16B0->MCR = 0x02<<9;
LPC_TMR16B0->MR3 = 1000;
LPC_TMR16B0->MR1 = 500;
LPC_TMR16B0->MR0 = 500;
LPC_TMR16B0->TCR = 0x01;
此帖出自
小平头技术问答
MR1这路得波形,现在要做一个频率1000Hz的小工程,周期相差不大,会有1us的上下波动,但占空比跟理论值比相差就比较大了,理论上是500us占空输出(50%),的实际输出有570us左右(误差了6-7%),不知道是哪里设置处理问题,还请多指教
一周热门 更多>