EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / TIMER DELAY PROBLEM……..

TIMER DELAY PROBLEM……..

|

Microcontroller › 8051 › TIMER DELAY PROBLEM……..

  • This topic has 2 replies, 3 voices, and was last updated 9 years, 8 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 13, 2016 at 11:59 am #4460
    maharudra bade
    Participant

    Hello…..friends……

    I am using timer0 and timer1 in mode 2,external clock=11.0592mhz,to generate pulses of 10us on two pins of uc with an delay of 100us  I am loading TLO=0XF6 for 10us

    & TH1=OXA3;for 100us delay…..here is my program……in output i am getting delay of approx…8ms…despite of 100us…..please anybody help me out this problem…..

    //OM NAMAH SHIVAY……
    //XTAL FREQ=11.0592 MHZ…
     
     
    #include <reg52.h> 
     
    sbit key   = P2^0;
     
    sbit wave1 = P2^4;
    sbit wave2 = P2^5;
     
    void timer1_init(void);
    void timer0_init(void);
    void _delay_ms(int ms);
     
    void main(void)
    {
    _delay_ms(10);
     
    key=1;wave1=wave2=0;
    T0=0;T1=0;
    timer0_init();
    timer1_init();
     
    while(1)
    {
     
    if(key == 0)
    {
    _delay_ms(10);
    TR1 = 1;TR0=1; //START THE TIMER…….
    wave1 = 1;
     
    while(TF1 == 0); //WAIT UNTILL TIMER OVERFLOWS…
    TR1 = 0; //STOP TIMER…
    TF1 = 0;         //CLEAR OVERFLOW FLAG…
    wave1=0;
     
    while(TF0==0);
    TF0=0;TR0=0;
     
    TR1=1;
    wave2 = 1;
    while(TF1==0);
    TF1=0;
    TR1=0;
    wave2 = 0;  
    }
     
    }
    }
    void timer0_init(void)
    {
    TMOD = 0x02; //timer0  8 bit auto-reload mode…..
    TH0 = 0xA3; //100 us pulse…..
    }
     
    void timer1_init(void)
    {
    TMOD = 0x20;
    TH1 = 0xF6; //10us pulse……
    }
    void _delay_ms(int ms)
    {
      int i,j;
     for(i=0;i<ms;i++)
      for(j=0;j<=1274;j++);
    }
     
    May 14, 2016 at 5:41 am #13921
    Vishnu V
    Participant

    Hi,

    How to create timer interup in python??

     

    May 16, 2016 at 7:43 am #13924
    Ashutosh Bhatt
    Participant

    to create 100 us delay using timer in mode 2 you have to load value 255-100 = 155 = 9Bh

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Do i need a buffer? February 7, 2026
  • ANOTHER OLD PROJECT REDO February 7, 2026
  • wall transformer polarity February 7, 2026
  • Supply vs performance query February 7, 2026
  • BPF February 7, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise