|
#include<reg52.h>
#define uint unsigned int
sbit pwm=P2^0;
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1){}
}
void PWM() interrupt 1
{ uint a=0;
uint b=10;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256 ;
a++;
if(a>20)
{ a=0;
}
if(a<=b)
{
pwm=1;
}
else pwm=0;
}
|
|