8051 Timer-Counter
8051 Timer-Counter
8051 TIMERS/COUNTERS
External interrupts
On-chip Timer/Counter
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Address/Data
Figure 1-2. Inside the 8051 Microcontroller Block Diagram
Timers /Counters
3
timer input
XTAL
÷ 12
oscillator
C/T = 0
TH0 TL0
C/T = 1
counter input
T0 Pin
1:start
Pin 3.4
TR0 TF0
0:stop
Gate
1. monitor by JNB
INT0 Pin
Pin 3.2 2. interrupt
hardware control
Timer/Counter 1
7
timer input
XTAL
÷ 12
oscillator
C/T = 0
TH1 TL1
counter input
C/T = 1
T1 Pin
1:start
Pin 3.5
TR1 TF1
0:stop
Gate
1. monitor by JNB
INT1 Pin 2. interrupt
Pin 3.3
hardware control
Registers Used in Timer/Counter
8
TH0 TL0
Timer 0
TH1 TL1
Timer 1
TCON Register (1/2)
11
(MSB) (LSB)
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
Timer 1 Timer 0 For Interrupts
Equivalent Instructions for the Timer
Control Register
13
For timer 0
SETB TR0 = SETB TCON.4
CLR TR0 = CLR TCON.4