0% found this document useful (0 votes)
126 views17 pages

8051 TIMERS: 8051 Microcontroller Suresh.P.Nair, HOD - ECE, RCET 1

This document discusses the timers in the 8051 microcontroller. It describes the TMOD and TCON registers used to configure the timers. Timer 0 and Timer 1 each have 3 modes - mode 0 is a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit autoreload timer. The document provides detailed diagrams explaining the operation of each timer mode. It also gives examples of programming the timers by setting the TMOD register values and calculating the timer clock frequency.

Uploaded by

Rs Abhinav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views17 pages

8051 TIMERS: 8051 Microcontroller Suresh.P.Nair, HOD - ECE, RCET 1

This document discusses the timers in the 8051 microcontroller. It describes the TMOD and TCON registers used to configure the timers. Timer 0 and Timer 1 each have 3 modes - mode 0 is a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit autoreload timer. The document provides detailed diagrams explaining the operation of each timer mode. It also gives examples of programming the timers by setting the TMOD register values and calculating the timer clock frequency.

Uploaded by

Rs Abhinav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

8051 TIMERS

8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

8051 Timer/Counter
OSC

12
C /T 0
C /T 1

TLx THx
(8 Bit)(8 Bit)

TFx
(1 Bit)

T PIN
INTERRUPT

TR
Gate
INT PIN
8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

TMOD Register

GATE:
When set, timer/counter x is enabled, if INTx pin is
high and TRx is set.
When cleared, timer/counter x is enabled, if TRx
bit set.
C/T*:
When set, counter operation (input from Tx input
pin).
8051 Microcontroller
, HOD - ECE , RCET
When cleared,Suresh.P.Nair
timer operation
(input3 from internal

TMOD Register

The TMOD byte is not bit addressable.

8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

TCON Register

8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

8051 Timer
Modes
8051 TIMERS
Timer 0

Timer 1

Mode
0
Mode
1
Mode
2
Mode
3

Mode
0
Mode
1
Mode
2

8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

TIMER 0
OSC

12
C /T 0
C /T 1

TL0 TH0

TF0

T 0 PIN

TR 0
Gate
INT 0 PIN

INTERRU
PT

TIMER 0 Mode 0
13 Bit Timer /
Counter
OSC

12
C /T 0
C /T 1

T 0 PIN

TL0
TH0
(5 Bit) (8 Bit)

TF0

TR 0
Gate
INT 0 PIN

Maximum Count = 1FFFh


(0001111111111111)

INTERRUPT

TIMER 0 Mode 1
16 Bit Timer /
Counter
OSC

12
C /T 0
C /T 1

T 0 PIN

TL0
TH0
(8 Bit) (8 Bit)

TF0

TR 0
Gate
INT 0 PIN

Maximum Count = FFFFh


(1111111111111111)

INTERRUPT

TIMER 0 Mode 2
8 Bit Timer / Counter with
AUTORELOAD
OSC

12
C /T 0
C /T 1

T 0 PIN

TL0
TH0
(8 Bit) (8 Bit)

TF0

TR 0
Gate

Reloa
d

INT 0 PIN

TH0
(8 Bit)

Maximum Count = FFh


(11111111)

INTERRUPT

TIMER 0 Mode 3
Two - 8 Bit Timer /
Counter
OSC

12
C /T 0
C /T 1

T 0 PIN

TL0
(8 Bit)

TF0

INTERRUPT

TH0
(8 Bit)

TF1

INTERRUPT

TR 0
Gate
INT 0 PIN

OSC

TR1

12

TIMER 1
OSC

12
C /T 0
C /T 1

TL1 TH1

TF1

T 1PIN

TR1
Gate
INT 1 PIN

INTERR
UPT

TIMER 1 Mode 0
13 Bit Timer /
Counter
OSC

12
C /T 0
C /T 1

T 1PIN

TL1
TH1
(5 Bit) (8 Bit)

TF1

TR1
Gate
INT 1 PIN

Maximum Count = 1FFFh


(0001111111111111)

INTERRUPT

TIMER 1 Mode 1
16 Bit Timer /
Counter
OSC

12
C /T 0
C /T 1

T 1PIN

TL1
TH1
(8 Bit) (8 Bit)

TF1

TR1
Gate
INT 1 PIN

Maximum Count = FFFFh


(1111111111111111)

INTERRUPT

TIMER 1 Mode 2
8 Bit Timer / Counter with
AUTORELOAD
OSC

12
C /T 0
C /T 1

T 1PIN

TL1
TH1
(8 Bit) (8 Bit)

TF1

TR1
Gate

Reloa
d

INT 1 PIN

TH1
(8 Bit)

Maximum Count = FFh


(11111111)

INTERRUPT

Programming Timers
Example: Indicate which mode and which timer are
selected for each of the following.
(a) MOV TMOD, #01H (b) MOV TMOD, #20H (c)
MOV TMOD, #12H
Solution: We convert the value from hex to binary.
(a) TMOD = 00000001, mode 1 of timer 0 is selected.
(b) TMOD = 00100000, mode 2 of timer 1 is selected.
(c) TMOD = 00010010, mode 2 of timer 0, and mode
1 of timer 1
are selected.

8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

16

Programming Timers
Find the timers clock frequency and its period for
various 8051-based system, with the crystal
frequency 11.0592 MHz when C/T bit of TMOD is 0.
Solution:

1/12 11.0529 MHz = 921.6


MHz;
T = 1/921.6 kHz = 1.085 us
8051 Microcontroller

Suresh.P.Nair , HOD - ECE , RCET

17

You might also like