Code:



#include<reg51.h>
sbit Pwm_pin=P1^0;
char h1=0xEB, l1=0xFF; 
void Pwm_High()
{
   Pwm_pin=1;
   while(!TF0);
   TF0=0; 
   TH0=h1;
   TL0=l1; 
   Pwm_pin=0; 
   while(!TF0); 
   TF0=0; 
}
void main()
{
   char high,low;
   int i=0,j=0;
   TMOD=0x01;
   while(1)
   {
       high=0xff;
       low=0xff; 
       h1=0xeb;
       l1=0xff;
       i=0;
       TR0=1;
       for(i=0;i<20;i++)
       {
           for(j=0;j<100;j++)
           TH0=high;
           TL0=low;
           Pwm_High();
       }
       high--;
       h1++;
   }
}