TMOD Special Function Register.

TMOD register

As we know there are 2 timer registers in 8051. Timer 0 and timer 1. Both of these registers use the same register called TMOD to set various timer operation modes.

TMOD is an 8-bit register, in which lower 4 bits are for Timer 0 and upper 4 bits are for Timer 1.

See table below. MSB ---- LSB
GATE
C/T
M1
M0
GATE
C/T
M1
M0
TIMER 1
TIMER 0

Bit Description:


BitTMOD Bit Function
7Gate -- OR gate enable bit which controls RUN/STOP of timer 1. Set to 1 by the program to enable the timer to run if bit TR1 in TCON is set and the signal on external interrupt is high. Cleared to 0 by the program to enable time to run if bit TR1 is set.
6C/T -- Set to 1 by the program to make timer 1 act as a counter by counting pulses from external input pins 3.5. Cleared to zero by the program to make timer act as a timer by counting internal frequency.
5M1 -- Timer/counter operating mode select bit 1. Set/cleared by the program to select mode.
4M0 -- Timer/counter operating mode select bit 0. Set/cleared by the program to select mode.
3Gate -- OR gate enable bit which controls RUN/STOP of timer 0. Set to 1 by the program to enable the timer to run if bit TR0 in TCON is set and the signal on external interrupt is high. Cleared to 0 by the program to enable time to run if bit TR0 is set.
2C/T -- Set to 1 by the program to make timer 0 act as a counter by counting pulses from external input pin 3.4. Cleared to zero by the program to make timer act as a timer by counting internal frequency.
1M1 -- Timer/counter operating mode select bit 1. Set/cleared by the program to select mode.
0M0 -- Timer/counter operating mode select bit 0. Set/cleared by the program to select mode.


M1
M0
MODE
OPERATING MODE
0
0
MODE 0
13 bit timer mode
8-bit timer/counter THx with TLx as 5-bit pre-scaler
0
1
MODE 1
16 bit timer mode.
16-bit timer/counter THx and TLx are cascaded with no pre-scaler.
1
0
MODE 2
8 bit auto reload.
8-bit auto reload-timer/counter  THx holds a value that’s to be reloaded in TLx each time it overflows.
1
1
MODE 3
Split timer mode












Comments

Popular posts from this blog

General puprose registers in 8051.

TCON Special Function register.