第一次接受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;
此帖出自
小平头技术问答
一周热门 更多>