flag=0;
void
timer0() interrupt 1
{
if(t0_flag == 0)
{
t1_flag = 1;
PWM = 1;
TH0 = (65536 - tpwm )/256;
TL0 = (65536 - tpwm)%256;
}
else
{
t0_flag = 0;
PWM = 0;
TH1 = (65536- 10000 + tpwm )/256;
TL1 = (65536 - 10000 + tpwm )%256;
}
}
tpwm/10000 是否就是代表占空比?如果不行的话要如何实现?
unsigned char tpwm; //高电平时间
flag=0;
void timer0() interrupt 1
{
if(flag == 0)
{
flag = 1;
PWM = 1;
TH0 = (65536 - tpwm )/256;
TL0 = (65536 - tpwm)%256;
}
else
{
flag = 0;
PWM = 0;
TH0 = (65536- 10000 + tpwm )/256;
TL0 = (65536 - 10000 + tpwm )%256;
}
}
tpwm/10000 是否就是代表占空比?如果不行的话要如何实现?
一周热门 更多>