![Sino Wealth SH79F3283 Скачать руководство пользователя страница 44](http://html1.mh-extra.com/html/sino-wealth/sh79f3283/sh79f3283_manual_1283063044.webp)
SH79F3283
44
7.8 Timer
7.8.1 Features
The SH79F3283 has four timers (Timer2, 3, 4, 5)
Timer2 is compatible with the standard 8052 and has up or down counting and programmable clock output function
Timer3 is a 16-bit auto-reload timer and can operate even in Power-Down mode
Timer4 is a 16-bit auto-reload timer and can be selected as a baud-rate generator
Timer5 is a 16-bit auto-reload timer
7.8.2 Timer2
The Timer 2 is implemented as a 16-bit register accessed as two cascaded data registers: TH2 and TL2. It is controlled by the
register T2CON and T2MOD. The Timer2 interrupt can be enabled by setting the ET2 bit in the IEN0 register. (Refer to
Interrupt Section for details)
C/T2
———
selects system clock (timer operation) or external in T2 (count operation) as the timer clock input. Setting TR2 allows
Timer2/Count2 Data Register to increment by the selected input.
Timer2 Modes
Timer2 has 4 operating modes: Capture/Reload, Auto-reload mode with up counter and Baud Rate Generator and
Programmable clock-output. These modes are selected by the combination of RCLK, TCLK and CP/RL2.
Table 7.27
Timer2 Mode select
C/T2
———
T2OE DCEN
TR2 CP/RL2 RCLK TCLK
MODE
X
0
X
1
1
0
0
0
16 bit capture
X
0
0
1
0
0
0
1
16 bit auto-reload timer
X
0
1
1
0
0
0
X
0
X
1
X
1
X
2
Baud-Rate generator
X
1
0
1
X
1
X
0
0
3
Programmable clock-output only
1
X
3
Programmable clock-output with Baud-Rate
generator
X
1
1
1
X
1
X
X
X
Not recommending
X
X
X
0
X
X
X
X
Timer2 stops, the T2EX channel still enable
Mode0: 16 bit Capture
In the capture mode, two options are selected by bit EXEN2 in T2CON.
If EXEN2 = 0, Timer2 is 16-bit timer or counter which will set TF2 on overflow to generate an interrupt if ET2 is enable.
If EXEN2 = 1, Timer2 performs the same operation, but a 1-to-0 transition at external input T2EX also causes the current
value in TH2 and TL2 to be captured to RCAP2H and RCAP2L respectively, In addition, a 1-to-0 transition at T2EX causes bit
EXF2 in T2CON to be set. The EXF2 bit, like TF2, can also generate an interrupt if ET2 is enabled.
0:Switch Off
1:Switch On
Block Diagram of 16 bit Capcture mode (Mode 0) of Timer2
Overflow flag
RCAP2H
RCAP2L
TL2
TH2
TF2
EXF2
+
&
0:Switch Off
1:Switch On
External falling
edge flag
Increment Mode
C/T2
=0
=1
Interrupt
Request
TR2
EXEN2
CP / RL2
T2EX
T2
1/12
System
Clock
TCLKP2