maximum time delay using timer interrupt of timer 1 of 8051

Discussion in 'Embedded Systems and Microcontrollers' started by bobparihar, Mar 3, 2015.

  1. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    i came to know that 8051 get interrupted whenever the timer overflows.. ie TF flag is set
    so if i use MODE 1 timer one... the maximum delay after which MCU get interrupted comes out to be 71 ms approx(65535*1.085 micro sec)

    so what if i need an interrupt delay more than 71 ms say i want an interrupt after 1sec? how it will possible?
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
    You make a loop. Reload the timer, reset the flag. Do it as many times as you need.
     
  3. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,000
    3,756
    Loop
    Inside of a loop
    Inside of a loop
    And so on...
    And so on...
    And so on...

    End
    End
    End
    End
    End
    End
     
  4. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
    I used for loop when we did it in class.
     
  5. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    A for loop is not the structure I would choose for using an interrupt. The idea is to count interrupts in the interrupt routine. This counter could be any number of bytes long, for a mind bendingly long delay. When the counter expires by reaching 0 or some prescribed value you set a flag(bit) in the interrupt routine. This bit is monitored by the non-interrupt code inside the "do forever" loop. Of course you also need a procedure for initializing the timer, the interrupt counter, and the done flag.
     
Loading...