我的本意是:当串口接收到数据时,PWM就输出一段时间,PWM控制步进电机,然后停止,等待串口继续传来数据,部分程序如下,为什么结果电机不动呢?
void __irq IRQ_PWM()
{
counter += 1;
VICVectAddr = 0x00;
}
main()中
{
...................
int distance = 50000;
while(1)
{
if(newdata == 1)
{
PWMPR = 0x00;
PWMMCR = 0x03;
PWMMR0 = 2765;
PWMMR6 = 1382;
PWMLER = 0x41;
PWMPCR = 0x4000;
PWMTCR = 0x09;
while(counter <= distance);
PWMTCR = 0x02;
PWMTCR = 0x00;
PWMPCR = 0x0000;
}
}
} |