#include<reg52.h>
#include<intrins.h>
sbit pwm = P0^0;
unsigned int i = 0;
void init()
{
TMOD = 0x02;
TH0 = 0xD2;
TL0 = 0xD2;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main()
{
init();
while(1);
}
void zd() interrupt 1
{
if(i>=400)
i=0;
if(i<30)
pwm = 1;
else
pwm = 0;
i++;
}
如上面程序,设置中断为50us,显然中断中的程序执行不会超过50us,那为什么此时此刻不能居中呢,而且按比例缩短中断时间,高电平的i为啥不是按比例增加呢
这个是方式2没错吖,自动重装