![Sino Wealth SH79F3283 Manual Download Page 45](http://html1.mh-extra.com/html/sino-wealth/sh79f3283/sh79f3283_manual_1283063045.webp)
SH79F3283
45
Mode1: 16 bit auto-reload Timer
Timer2 can be programmed to count up or down when configured in its 16-bit auto-reload mode. This feature is invoked by the
DCEN (Down Counter Enable) bit in T2MOD. After reset, the DCEN bit is set to 0 so that Timer2 will default to count up. When
DCEN is set, Timer2 can count up or down, depending on the value of the T2EX pin.
When DCEN = 0, two options are selected by bit EXEN2 in T2CON.
If EXEN2 = 0, Timer2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer
registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L, which are pressed by software.
If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This
transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if ET2 is enabled.
TF2
C/T2
=0
=1
The Block Diagram of Auto Relode Mode (Mode 1)of Timer2 (DCEN=0)
RCAP2L
RCAP2H
EXF2
+
0:Switch Off
1:Switch On
Increment Mode
0:Switch Off
1:Switch On
External Falling
Edge flag
TL2
TH2
+
T2EX
T2
Interrupt
Request
Overflow
Flag
TR2
EXEN2
1/12
System
Clock
TCLKP2
Setting the DCEN bit enables Timer2 to count up or down. When DCEN = 1, the T2EX pin controls the direction of the count,
and EXEN2’s control is invalid.
A logical “1” at T2EX makes Timer2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also
causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively.
A logical “0” at T2EX makes Timer2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H
and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers.
The EXF2 bit toggles whenever Timer2 overflows or underflows and can be used as a 17th bit of resolution. In this operating
mode, EXF2 does not flag an interrupt.
TF2
TR2
C/T2
The Block Diagram of Auto-Reload Mode ( Mode 1) of Timer2 (DCEN=1)
T2EX
EXF2
Toggle
1.T2EX=1
,
Timer2 is up counter
2.T2EX=0
,
Timer2 is down counter
T2
TL2
TH2
RCAP2L
RCAP2H
FFH
FFH
=0
=1
0:Switch Off
1:Switch On
Overflow
Flag
Interrupt
Request
1/12
System
Clock
TCLKP2