TCON (Timer Control Register)
The 8051 microcontroller has a unique function register called the TCON (Timer Control Register). In order to provide precise output, timers and counters are controlled by it. The data in the registers may overflow if these timers and counters are not under control. Thus, the TCON is utilized to control the timers and counters. The structure in detail is displayed below.
Structure of TCON
The TCON register is an 8-bit register, where each bit has a specific function:
Here’s what each bit represents:
Bit |
Bit Name |
Description |
---|---|---|
7 |
TF1 (Timer 1 Overflow Flag) |
Set to 1 when Timer 1 overflows else 0. |
6 |
TR1 (Timer 1 Run Control Bit) |
Set to 1 to start Timer 1, and set to 0 to stop Timer 1. |
5 |
TF0 (Timer 0 Overflow Flag) |
Set to 1 when Timer 0 overflows else 0. |
4 |
TR0 (Timer 0 Run Control Bit) |
Set to 1 to start Timer 0, and set to 0 to stop Timer 0. |
3 |
IE1 (Interrupt 1 Edge Flag) |
Set to 1 when an external interrupt 1 occurs else 0. |
2 |
IT1 (Interrupt 1 Type Control Bit) |
Set to 1 to configure external interrupt 1 as edge-triggered, and set to 0 for level-triggered. |
1 |
IE0 (Interrupt 0 Edge Flag) |
Set to 1 when an external interrupt 0 occurs else 0. |
0 |
IT0 (Interrupt 0 Type Control Bit) |
Set to 1 to configure external interrupt 0 as edge-triggered, and set to 0 for level-triggered. |
8051 Timers and Counters
8051 microcontrollers are mainly used to speed up our tasks because they are very easy to use and they are also fast to complete tasks easily. These microcontrollers have one main feature which is Timers and counters. This feature is widely used in microcontrollers to measure the time and as well as to count the events or tasks. By learning about these timers and counters ,we can make good embedded systems. In this article let us see how these counters and timers work in microcontrollers.
Table of Content
- 8051 Timers and Counters
- Types
- What is Timer 0 (T0) ?
- What is Timer 1 (T1) ?
- TCON and TMOD
- Timer Counter Modes
- What is Counter Mode ?