• Timer interrupt is used when we know the time of certain events that occur on certain time .
  • In 8051 there are two timer interrupts called timer 0 ( TF0 ) and timer 1 ( TF1 ).TF mean timer flag.
  • This timer flag (TF) is raised when the timer rolls over (reach at its programmed value ) and microcontroller jumps to timer’s interrupt routine.
  • without timer with interrupt we have to poll the TF and  wait until the TF is raised.
  • The problem with this method is that the microcontroller is tied down while waiting for TF to be raised, and can not do anything else.
  • Using timer with interrupts we can solves this problem and, avoids tying down the controller.
  • If the timer interrupt in the IE register is enabled, whenever the timer rolls over, TF is raised, and the microcontroller is interrupted in whatever it is doing, and jumps to the interrupt vector table to service the ISR.
  • In this way, the microcontroller can do other until it is notified that the timer has rolled over.

 

 Following registers are used In timer with interrupt

 

TMOD

 

 tmod

  • G=0 mean, timer control by software mechanism.
  • G=1 mean, timer control by hardware mechanism.
  • C/T0= 0 mean, timer operation.
  • C/T0= 1 mean, counter operation.

 

 

M1

M0

MODE OF OPERATION

0

0

Mode 0 (13 bit)

0

1

Mode 1 (16bit)

1

0

Mode (8bit auto reload mode )

1

1

Split timer mode

 

 

 

 

 

TCON

 

 tcon

 

  • TR1=0 mean, to stop timer 1 .
  • TR1=1 mean, to start timer 1.
  • TR0=0 mean, to start timer 0.
  • TR0=1 mean, to start timer 0.
  • TF1=1 mean overflow condition occur in Timer 1.
  • TF1=0 mean Timer 1 is in running condition.
  • TF0=1 mean overflow condition occur in Timer 0.
  • TF0=0 mean Timer 0 is in running condition.
  • IT1=1 mean interrupt trigger is negative edge sensitive.
  • IT1=0 mean interrupt trigger is positive edge sensitive.
  • IT0=1 mean interrupt trigger is negative edge sensitive.
  • IT0=0 mean interrupt trigger is positive edge sensitive.
  • IE1=1 mean interrupt enable Timer 1.
  • IE1=0 mean interrupt enable Timer 1.
  • IE0=1 mean interrupt enable Timer 0.
  • IE0=0 mean interrupt enable Timer 0.

 

 

IE

 

 IE

  • EA=1 , enable this register’s use.
  • EA=0 , disable this register’s use.
  • ES=1, enable serial interrupt.
  • ES=0, disable serial interrupt.
  • ET2=1, enable Timer 2 interrupt (8052 feature).
  • ET2=0, disable Timer 2 interrupt (8052 feature).
  • ET1=1, enable Timer 1 interrupt.
  • ET1=0, disable Timer 1 interrupt.
  • ET0=1, enable Timer 0 interrupt.
  • ET0=0, disable Timer 0 interrupt.
  • EX1=1, enable external/hardware  interrupt(INT1).
  • EX1=0, disable external/hardware  interrupt(INT1).
  • EX0=1, enable external/hardware  interrupt(INT0).
  • EX0=0, disable external/hardware  interrupt(INT0).

 

 

TH1 & TL1

 

 th

  • This is each 8 bit register used to load the value up to which timer run.
  • On reaching on this value loaded in TH and TL, timer flag is raised