Skip to content
The Computer Science
TheCScience
  • Engineering Subjects
    • Human Values
    • Computer System Architecture
    • Microprocessor
    • Digital Communication
    • Internet of Things
  • NCERT Solutions
    • Class 12
    • Class 11
  • Solutions
    • HackerRank
      • C Solutions
      • C++ Solutions
      • Java Solutions
      • Python Solutions
      • Algorithms Solutions
      • Data Structures Solutions
    • HackerEarth Solutions
    • Leetcode Solutions
  • JEE 2027
The Computer Science
TheCScience

8051 Microcontroller Timers and Counters

YASH PAL, April 13, 2026April 13, 2026

8051 Microcontroller Timers and Counters – Many microcontroller systems require the counting of external events. It can be achieved by two 16-bit up counters, named T0 and T1. These two counters are available to the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or programmed to count external pulses as a counter. The counters are divided into two 8-bit registers: Timer low (TL0 and TL1) and Timer high (TH0 and TH1). There are two registers to control all counter actions.

  1. Timer Mode Control Register (TMOD)
  2. Timer/Counter Control Register (TCON)

The bit definitions of the two special function registers TCON and TMOD are shown in the tables below.

Table of Contents

  • The Timer Control Special Function Register (TCON)
  • The Timer Mode Control (TMOD) Special Function Register
  • Timer Control Logic
    • Modes of Operations
  • Counters

The Timer Control Special Function Register (TCON)

76543210
TF1TR1TR0TF0TR0IE1 IE0IT0
BitSymbolFunction
7TF1Timer 1 Overflow flag. Set when the timer rolls from all 1s to 0. Cleared when the processor vectors to execute the interrupt service routine located at program address 001Bh.
6TR1Timer 1 run control bit. Set to 1 by the program to enable the timer to count; cleared to 0 by the program to halt the timer. Does not reset the timer.
5TF0Timer 0 Overflow flag. Set when the timer rolls from all 1s to 0. Cleared when the processor vectors to execute an interrupt
4TR0Timer 0 run control bit. Set to 1 by the program to enable the timer to count; cleared to 0 by the program to halt the timer. Does not reset the timer.
3IE1External interrupt 1 Edge flag. Set to 1 when a high-to-low edge signal is received on port 3, pin 3.3 (INT1). Cleared when the processor vectors to the interrupt service routine located at program address 0013h. Not related to timer operations.
2IT1External interrupt 1 signal type control bit. Set to 1 by the program to enable external interrupt 1 to be triggered by a falling edge signal. Set to 0 by the program to enable a low-level signal on external interrupt 1 to generate an interrupt.
1IE0External interrupt 0 Edge flag. Set to 1 when a high-to-low edge signal is received on port 3 pin 3.2 (INT0). Cleared when the processor vectors to the interrupt service routine located at program address 0003h. Not related to timer operations.
0IT0External interrupt 0 signal type control bit. Set to 1 by the program to enable external interrupt 0 to be triggered by a falling edge signal. Set to 0 by the program to enable a low-level signal on external interrupt 0 to generate an interrupt. Bit addressable as TCON.0 to TCON.7.
TCON SFR

The Timer Mode Control (TMOD) Special Function Register

Timer control mode control special function register
Timer control mode control special function register
BitSymbolFunction
7/3GateOR gate enables the bit that controls the RUN/STOP of timer 1/0. Set to 1 by the program to enable the timer to run if bit TR 1/0 in TCON is set and the signal on the external interrupt INT1/0 pin is high. Cleared to 0 by the program to enable the timer to run if bit TR1/0 in TCOn is set.
6/2C / TSet to 1 by program to make timer 1/0 act as a counter by counting pulses from external input pins 3.5 (T1) or 3.4 (T0). Cleared to 0 by the program to make the timer act as a timer by counting internal frequency.
5/1M1Timer/counter operating mode select bit 1. Set/cleared by program to select mode.
4/0M0Timer/counter operating mode select bit 0. Set/cleared by program to select
M1 M0 Mode
0 0 0
0 1 1
1 0 2
1 1 3
TMOD is not bit addressable
TMOD SFR

Timer Control Logic

If a counter is designed and programmed to be a timer, it will count the internal clock frequency of the 8051 microcontroller divided by 1210. The resultant timer clock is gated to the timer by means of the circuit shown in the figure below. The C/T bit in the TMOD register must be set to low (0) for timer operation. In other words, the counter is configured as a timer.

Timer counter control logic of 8051 microcontroller
Timer counter control logic of the 8051 microcontroller

Modes of Operations

Each counter/timer may operate in one of the four possible modes, by substituting the proper values of M1 and M0 for the corresponding timer.

Mode0 (M1 M0 = 00) – In this mode, 8 bits of TH0/TH1 and 5 bits of TL0/TL1 are used. The 13-bit counter can hold the values between 0000H and 1FFFH. Therefore, the maximum count of the counter is 1FFFH; after that, it resets to 000H.

Timer mode 0
Timer mode 0

Mode1 (M1 M0 = 01) – This mode of timer/counter is similar to mode 0, with the difference that it uses the full counter of 16 bits, 0000H to FFFFH.

Timer mode 1
Timer mode 1

Mode2 (M1 M0 = 10) – In this mode, TL0/TL1 is used as an 8-bit counter, and TH0/TH1 hold a value that is loaded to TL0/TL1 every time TL0/TL1 overflows from FFH to 00H. The timer flag (TF0/TF1) is also set when TL0/TL1 overflows.

Timer mode 2
Timer mode 2

Mode3 (M1 M0 = 11) – Timer 0 and timer 1 may be programmed to work independently in any of the mode 0, mode 1, or mode 2. In mode 3, the timers do not operate independently.

timer mode 3
timer mode 3

Counters

The only difference between counting and timing is the source of clock pulses to the counters. When used as a timer, the clock pulses are sourced from the oscillator through the divide-by-12 circuit. When using a counter, pin T0 supplies pulses to counter 0 and pin T1 to counter. The C/T bit in TMOD must be set to 1 to select the counter.

engineering subjects Microprocessor microprocessor

Post navigation

Previous post
Next post

Introduction to Microprocessor
Generations of Computer
Microprocessor Types
Types of Computer Systems
Types of Programming Languages
Basic Computer Structure
Interfacing Logic Devices
Number System in Computer
Number System Arithmetic – Addition & Subtraction

Microprocessor as CPU
8085 Microprocessor Architecture
Pin Configuration of 8085 Microprocessor
Demultiplexing of Address and Data Bus in 8085 Microprocessor
Basic Operations of the 8085 Microprocessor
Memory Organization in 8085 Microprocessor

Microprocessor memory structure
Memory Interfacing with 8085 Microprocessor
Memory address decoding in a microprocessor
Input/Output Interfacing in Microprocessor

8085 Microprocessor Programming Model
8085 Assembly Language Programming
8085 Microprocessor Instructions
Microprocessor Programming Steps
Flowchart Design of a Program
8085 Microprocessor Data Transfer Instructions
8085 Microprocessor Arithmetic Instructions
8085 Microprocessor Logical Instructions
8085 Microprocessor Branch Instructions
8085 Microprocessor Machine-Processor Control Instructions
Basic Structure of an Assembly Language Program
Programming Techniques for Repeated Tasks
Debugging of a Microprocessor Program

8085 Microprocessor Timing Operations
Timing Diagram of 8085 Microprocessor
Time Delay in Microprocessor
Stack in 8085 Microprocessor
Subroutine in 8085 Microprocessor
MACRO in Microprocessor

Interrupts in 8085 Microprocessor
Digital to Analog Converter (DAC) in Microprocessor
Analog to Digital Converter (ADC) in Microprocessor

Programmable Peripheral Interface
8255 (PPI) Programmable Peripheral Interface
Programmable Interval Timer (PIT) 8253/8254
Programmable Interrupt Controller (PIC) 8259
Direct Memory Access (DMA) Controller 8257

8086 Microprocessor Architecture, Instructions, and Pin Diagram
Addressing Modes of the 8086 Microprocessor
Instruction Set of 8086 Microprocessor
8088 Microprocessor Architecture with Pin Diagram
Difference between 8085, 8086, and 8088 Microprocessors
80186 Microprocessor Architecture
80286 Microprocessor Architecture & Features
80386 Microprocessor Architecture & Features
80486 Microprocessor Architecture & Features
80586 (Pentium) Microprocessor Architecture & Features

8051 Microcontroller Architecture
8051 Microcontroller Memory Organization
8051 Microcontroller Pin Configuration & Programming Model
8051 Microcontroller Timers and Counters
Serial Communication in 8051 Microcontroller
Interrupts of the 8051 Microcontroller
Addressing Modes of the 8051 Microcontroller
Intel MMX Architecture
Dual Core Processor

LED & Multiplexed Display Interfacing with Microprocessor
Liquid Crystal Display (LCD) Pin Configuration & Interfacing
Matrix Keyboard Interfacing with Microprocessor
8279 Keyboard/Display Controller
Programmable Communication Interface (USART) 8251
Serial Communication Standards in Microprocessor
Computer System Standard Buses

TheCScience

At TheCScience.com, our mission is to make quality education accessible to everyone. We provide in-depth, easy-to-understand articles covering Secondary, Senior Secondary, and Graduation-level subjects.

Pages

About US

Contact US

Privacy Policy

DMCA

Our Tools

Hosting - get 20% off

Engineering Subjects

Internet of Things

Human Values

Digital Communication

Computer System Architecture

Microprocessor

Programming Tutorials

Data Structure and Algorithm

C

Java

NCERT

Class 12th

©2026 TheCScience | WordPress Theme by SuperbThemes