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:
Bit | TMOD Bit Function |
---|---|
7 | Gate -- 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. |
6 | C/ |
5 | M1 -- Timer/counter operating mode select bit 1. Set/cleared by the program to select mode. |
4 | M0 -- Timer/counter operating mode select bit 0. Set/cleared by the program to select mode. |
3 | Gate -- 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. |
2 | C/ |
1 | M1 -- Timer/counter operating mode select bit 1. Set/cleared by the program to select mode. |
0 | M0 -- 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
Post a Comment