void Timer1(void) interrupt 3
{
TR1 = 0;
TH1 = (65536-50000)/256; //50ms
TL1 = (65536-50000)%256;
TR1 = 1; //启动定时器T1
if(start)
{
Time1onecnt ++;
if(Time1onecnt <= (PWM0*20))
{
drive0 = 1;
}
else
{
drive0 = 0;
}
if(Time1onecnt <= (PWM1*20))
{
drive7 = 1;
}
else
{
drive7 = 0;
}
if(Time1onecnt == 1200) //60s
{
Time1onecnt = 0;
algorithm = 1;
}
}
}
为什么这个中断程序的中断周期时间为100s,而不是设定的60s(本人所使用的单片机为W77E516) |