Specific Timers logic +At89c51

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Sep 15, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    1. I used to do programming in which I use one timer as delay timer for generating specific delay & other for general purpose timer for periodically updating some vraibles/pin/ etc . in interrupt.
    I am using 11.0592Mhz crystal

    2. But now I have to also use uart. Now uart use Timer 1. Now uart remain active for entire time.
    So I have left with only one timer.

    3. I have a logic in which general timer will keep on running at 1ms interrupt, & if I have to create some specific delay. I set up a global flag, which start counting in interrupt for specific time & generate the delay.

    Problem with above approach is, when I have to create specific delay:
    1. Time has to be factor of 1ms. I cannot make 1.5ms
    2. Max error rate in generating delay is +- 1ms.
    3. If I set periodic timer below 1ms than interrupt happens lots of time in 1ms & adds unnecessary cycles like PUSH,POP everytime.

    Does anyone has better approach to do. I want to cretae specific delay also & don't want to disturb periodic updation of variables/pins etc
  2. Arm_n_Legs

    Active Member

    Mar 7, 2007
    Program your timer at 0.5ms then you can get 1ms (on the 2nd interrupt) and 1.5ms (on the 3rd interrupt).
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    If it helps your error estimate is 2x too large. The max error is half the period.