做的PWM直流电机调速,我用定时器0定时产生PWM脉冲,定时器1计时50msTMOD = 0x11;
TH0 = 0x0FF;
TL0 = 0x9C;//100us
TH1=0x3C;
TL1=0x0B0;//50ms
EA = 1;
ET0 = 1;
TR0 = 1;
ET1 = 1;
TR1 = 1;
关了T1PWM波形正常,但是只要开了T1波形就不对了,像图中那样,中间会有一端高电平。外部中断1检测速度脉冲,这个没啥影响。求各位大佬这个怎么解决啊
void
time_0()interrupt 1
{
TR0=0;
num++;
if(num<PWM)
ENA=1; //L298N使能端
else
ENA=0;
if(num>100) num=1;
TMOD = 0x01;
TH0 = 0x0FF;//100us
TR0=1;
}
void INT0_INTERRUPT()interrupt 0
{
EX0=0;
velocity++;
EX0=1;
}
void time_1()interrupt 3
{
TR1=0;
count++;
if(count==51)
{
sprintf(dsp,"%3d", velocity);
display_string(7,4,dsp);
ldelay(100);
count=1;
velocity=0;
}
TH1=0x3c;
TL1=0x0b0;
TR1=1;
}
-
一周热门 更多>