8051_timer
    
    This 8051project shows the timer operation for 500 microseconds using Timer0. To simulate circuit in this project, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Run Transient analysis (Oscillograph) from Simulation menu.
  
     In this circuit, Port P1 is set as the output port. An internal timer counts from the specified value to FFFF during the 500-microsecond time. A series of pulses will appear at P1 to indicate the duration of timer operation.
 
     The source code written either in C or Assembly language can be viewed from the
          code editor window 
     
 
     The program is as shown:
     
    #include<8051.h>
     void main()
     
      {
     TH0 = 0x0fe; // To get the timer operation for 500ยต seconds set T0 as FE5F
     TL0 = 0x5f;
     TMOD = 0x01; // Mode 1 (16-bit timer mode)
     TR0 = 1; // TR0 is set to ‘1’ to turn On Timer 0 
     
     for ( ; ; ) // Infinite loop
     {
     P1_0 = P1_0 ^ 1; // Port1.0 is xor-ed with value ‘1’, which will give 
         complement the previous value
     If (TF0==1) // TF0 will set when the timer rolls over
     {
        TR0 =0; // Reset to turn Off Timer 0
           break;
    }
     }
      }
    
    
     
    
      The source code in the 
    code editor window 
 has to be  
    compiled 
 after making any modifications 
    (editing). 
Also the code can be 
    debugged 
 during
     simulation.