52 timer/counter T2 register description

Publisher:技术掌门Latest update time:2016-10-26 Source: eefocusKeywords:Timer  Counter  Register Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
There are two timers T0 and T1 in the 51 series of MCUs. There is a lot of information on the Internet. The 52 MCU has one more timer T2 and 128 bytes of RAM than the 51 MCU. The function of timer T2 is more powerful than T1 and T0, but there is not much information describing it, probably because it is rarely used. It is a 16-bit timer/counter with automatic reload and capture capabilities. Its counting clock source can be the internal machine cycle or the external clock pulse input by P1.0. The function description of T2's control register is as follows:

T2CON (T2 control register), byte address0C8H:

Bit address 0CFH 0CEH 0CDH 0CCH 0CBH 0CAH    0C9H    0C8H

Symbol TF2 EXF2 RCLK TCLK EXEN2 TR2      C/T2    CP/RT2

The definitions of each are as follows:

TF2: Timer/Counter 2 overflow flag, set when T2 overflows and request an interrupt. It can only be cleared by software, but when T2 is used as a baud rate generator (i.e. RCLK=1 or TCLK=1), TF2 is not set when T2 overflows.

EXF2: When EXEN2 = 1, and a negative transition occurs on the T2EX pin (P1.0) causing T2 to be captured or reloaded, EXF2 is set and an interrupt is requested. EXF2 can only be cleared by software.

RCLK: Serial receive clock flag, which can only be set or cleared by software; used to select T1 (RCLK=0) or T2 (RCLK=1) as the serial receive baud rate generator

TCLK: serial transmission clock flag, which can only be set or cleared by software; used to select T1 (TCLK=0) or T2 (TCLK=1) as the baud rate generator for serial transmission

EXEN2: External enable flag of T2, which can only be set or cleared by software; EXEN2=0: Disable external clock to trigger T2; EXEN2=1: When T2 is not used as a serial baud rate generator, allow external clock to trigger T2. When a negative transition is input to the T2EX pin, it will cause T2 to be captured or reloaded, and set EXF2 to request an interrupt.

TR2: T2 start control flag; TR2=0: stop T2; TR2=1: start T2

C/T2: T2 timing mode or counting mode selection bit. Can only be set or cleared by software; C/T2=0: Select T2 as timer mode; C/T2=1: Select T2 as counter mode, falling edge triggered.

CP/RT2: Capture/reload flag, which can only be set or cleared by software. When CP/RT2=0, the reload mode is selected. At this time, if T2 overflows (EXEN2=0) or the T2EX pin (P1.0) has a negative transition (EXEN2=1), T2 will be reloaded; when CP/RT2=1, the capture mode is selected. At this time, if the T2EX pin (P1.0) has a negative transition (EXEN2=1), T2 capture operation will be caused. However, if RCLK=1 or TCLK=1, the CP/RT2 control bit does not work and is forced to work in the timer overflow automatic reload mode.

T2MOD (mode register), byte address0C9H:

D7     D6     D5     D4     D3     D2     D1     D0

--      --      --      --       --      --      T2OE   DCEN

T2OE: T2 output enable bit. When T2OE=1, the clock is allowed to output to P1.0. (Only for80C54/80C58 valid)

DCEN: Down-counting enable bit. DCEN=1 allows T2 to count down, otherwise it counts up.

The data registers TH2 and TL2 of T2 are used in the same way as T0 and T1, while the capture registers RCAP2H and RCAP2LOnly in the capture mode, the values ​​of TH2 and TL2 are automatically saved when a capture operation occurs.

    The above is the description of the relevant registers of T2. In fact, the usage is similar to T0 and T1, but the functions are enhanced and there are more settings. I hope it will be helpful to you.

Keywords:Timer  Counter  Register Reference address:52 timer/counter T2 register description

Previous article:Dynamic configuration of interrupt vector table in ARM system
Next article:Distributed Control System of Humanoid Robot Based on CAN Bus

Recommended ReadingLatest update time:2024-11-16 12:49

STC89C52 controls 74HC595 and 74HC138 dual-color 16x16 dot matrix screen to display Chinese characters in a loop
Introduction In addition to using MAX7219, some common LED dot matrices also use 74HC595. The former can be refreshed actively, while the latter requires the host computer to actively scan and refresh. The one in my hand is a 16x16LED dot matrix module from Defeilai. The model printed on the board is LY-LED16x16B V2
[Microcontroller]
STC89C52 controls 74HC595 and 74HC138 dual-color 16x16 dot matrix screen to display Chinese characters in a loop
CS5212 replaces RTD2166 DP to VGA schematic diagram
Taiwan CAPSTONECS5212 is a professionally designed DP port to VGA converter chip, which combines the display port input interface and the analog RGB DAC output interface. The embedded MCU is based on the industrial standard 8051 core microcontroller. Brief description of CS5212 features 2-channel VES
[Embedded]
CS5212 replaces RTD2166 DP to VGA schematic diagram
52. STM32 DAC experiment
1. The principle of digital-to-analog conversion DAC Limitations of STM32 DAC: Only the large-capacity STM32F103x (Flash above 256K) models have the DAC function. 1. Principle of digital-to-analog conversion The DAC module has 2 converters, one channel each. 2. Main features of the STM32DAC module 3. DAC module
[Microcontroller]
52. STM32 DAC experiment
Functions corresponding to the STC89C52 microcontroller pins and examples explained
First attach a pin diagram of stc89C52 Just looking at the pins is not enough. Let’s take a look at what the actual picture looks like. 1. P1^0~7 corresponds to eight diodes The physical picture of the secondary tube is as follows:   From top to bottom, they correspond to P1^0 ~ P1^7 in the pins. Here is a rel
[Microcontroller]
Functions corresponding to the STC89C52 microcontroller pins and examples explained
Introduction to C51/C52 MCU interrupt (EXTI) (I)
1. What is an interrupt? Interrupt: interrupt the current work, execute the program in the interrupt function, and then come back to execute the unfinished program after the execution is completed. As shown in the following figure: 2. Interrupt source and interrupt number Note: When writing an interrupt service
[Microcontroller]
Introduction to C51/C52 MCU interrupt (EXTI) (I)
TT Electronics launches EBW5216 busbar shunt resistor
Compact electron beam welded shunt resistors enable accurate current sensing in the hundreds of amperes range for automotive, power management and industrial applications Woking, UK, 31 May 2023 – TT Electronics, a global supplier of engineered electronics for performance-critical applications, to
[Power Management]
Qinheng 8-bit USB device microcontroller: CH552 overview
Overview The CH552 chip is an enhanced E8051 core microcontroller compatible with the MCS51 instruction set. 79% of its instructions are single-byte single-cycle instructions, and the average instruction speed is 8 to 15 times faster than the standard MCS51. CH552 supports the highest system frequency of 24MHz, buil
[Microcontroller]
Qinheng 8-bit USB device microcontroller: CH552 overview
stc12c2052ad pwm program
#include reg52.h sfr CCON =0xD8; //PCA control register sfr CMOD =0xD9; sfr CL =0xe9; sfr CH =0xF9; sfr CCAP0L=0xea; sfr CCAP1L=0xeb; sfr CCAP0H=0xfa; sfr CCAP1H=0xfb; sfr CCAPM0=0xda; sfr CCAPM1=0xdb; sbit CR=0xde; //Bit addressing void main(void) {   CMOD=0x02; //Use system clock, clock input source frequency
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号