• The format of TMOD register is,
• The lower four bits of TMOD register is used to control timer-0 and the upper four bits are used to control timer-1.
• The two timers can be independently program to operate in various modes.
• The TMOD register has two separate two bit field M0 and Ml to program the operating mode of timers. The operating modes of timers are mode-0, mode-1, mode-2 and mode-3. In all these operating modes the oscillator clock is divided by 12 and applied as input clock to timer.
o In mode-0 the timer register is configured as 13-bit register.
o For timer-1 the 8 bits of TH1 and lower 5 bits of TL1 are used to form 13-bit register.
o For timer-0 the 8-bit of TH0 and lower 5 bits of TL0 are used to form 13-bit register.
o The upper three bits of TL registers are ignored.
o For every clock input to timer the 13-bit timer register is incremented by one When the timer count rolls over from all 1’s to all 0’s, (i.e., 1 1111 1111 1111 to 0 0000 0000 0000) the timer interrupt flag in TCON register is set to one.
o The mode-1 is same as mode-0 except the size of the timer register. In mode-1 the TH and TL registers are cascaded to form 16-bit timer register.
o In mode-2, the timers function as 8-bit timer with automatic reload feature. The TL register will function as 8-bit timer count register and the TH register will hold an initial count value.
o When the timer is started, the initial value in TH is loaded to TL and for each clock input to timer the 8-bit timer count register is incremented by one.
o When the timer count rolls over from all 1’s to all 0’s (i.e., 1111 1111 to 0000 0000), the timer interrupt flag in TCON register is set to one and the content of TH register is reloaded in TL register and the count process starts again from this initial value.
o In mode-3, the timer-0 is configured as two separate 8-bit timers and the timer-1 is stopped.
o In mode-3 the TL0 will function as 8-bit timer controlled by standard timer-0 control bits and the TH0 will function as 8-bit timer controlled by timer-1 control bits.
o While timer-0 is programmed in mode-3, the timer-0 can be programmed in mode-0, 1 or 2 and can be used for an application that does not require an interrupt.
o The C/T(Low) bit of TMOD register is used to program the counter or timer operation of the timer. When C/T bit is set to one, the timer will function as event counter. The C/T(Low) bit is programmed to zero for timer operation.
o The timer will run only if clock input is allowed.
o When GATE = 1, the clock input to timer is allowed only if the signal at pin is high and when GATE =0 the signal at INT (low) pin is ignored.