这两天利用stc12c5a60s2控制舵机转动,仅刚刚上电的时候转一下,以后就不动了,不知道什么原因,请大神解答,急求
#include <reg52.h>
sbit PWM=P0^0;
unsigned char counter,a;
void InitTimer0(void)
{
TMOD = 0x11;
TH0 = 0x53;
TL0 = 0x33;
TH1=0xd4;
TL1=0xcd;
ET1=1;
EA = 1;
ET0 = 1;
TR0 = 1;
PWM=1;
}
void main(void)
{
InitTimer0();
while(1)
{}
}
void Timer0Interrupt(void) interrupt 1 //中断0,控制20ms中断输出
{
TH0 = 0x53;
TL0 = 0x33;
if(counter>=10) //当20ms后重新初始化
{
InitTimer0();
}
else counter++;
//add your code here!
}
void Timer1Interrupt(void) interrupt 3 //中断1,控制在1ms以后使信号为零
{
TH1 = 0xd4;
TL1 = 0xcd;
if(a>=2)
{TR0=0;
PWM=0;}
//add your code here!
}
请大神看下这个程序有什么问题,或者分享一些舵机资料也行,跪谢
|