XC886/888CLM
Timers
User’s Manual
13-14
V1.3, 2010-02
Timers, V 1.0
13.2
Timer 2 and Timer 21
Timer 2 and Timer 21 are 16-bit general purpose timers that are functionally identical.
Both have two modes of operation, a 16-bit auto-reload mode and a 16-bit one channel
capture mode and can function as a timer or counter in each of its modes. As a timer,
the timers count with an input clock of PCLK/12 (if prescaler is disabled). As a counter,
they count 1-to-0 transitions on pin T2. In the counter mode, the maximum resolution for
the count is PCLK/24 (if prescaler is disabled).
Note: Subsequent sections describe the functionalities of Timer 2, which is valid also for
Timer 21 unless otherwise stated.
13.2.1
Basic Timer Operations
Timer 2 can be started by using TR2 bit by hardware or software. Timer 2 can be started
by setting TR2 bit by software. If bit T2RHEN is set, Timer 2 can be started by hardware.
Bit T2REGS defines the event on pin T2EX, falling edge or rising edge, that can set the
run bit TR2 by hardware. Timer 2 can only be stopped by resetting TR2 bit by software.
13.2.2
Auto-Reload Mode
The auto-reload mode is selected when the bit CP/RL2 in register T2CON is zero. In this
mode, Timer 2 counts to an overflow value and then reloads its register contents with a
16-bit start value for a fresh counting sequence. The overflow condition is indicated by
setting bit TF2 in the T2CON register. At the same time, an interrupt request to the core
will be generated (if interrupt is enabled). The overflow flag TF2 must be cleared by
software.
The auto-reload mode is further classified into two categories depending upon the DCEN
control bit in register T2MOD.
13.2.2.1
Up/Down Count Disabled
If DCEN = 0, the up-down count selection is disabled. The timer, therefore, functions as
a pure up counting timer only. The operational block diagram is shown in
If the T2CON register bit EXEN2 = 0, the timer starts to count up to a maximum of FFFF
H
once the timer is started by setting the bit TR2 in register T2CON to 1. Upon overflow,
bit TF2 is set and the timer register is reloaded with the 16-bit reload value of the RC2
register. This reload value is chosen by software, prior to the occurrence of an overflow
condition. A fresh count sequence is started and the timer counts up from this reload
value as in the previous count sequence.
If EXEN2 = 1, the timer counts up to a maximum of FFFF
H
once TR2 is set. A 16-bit
reload of the timer registers from register RC2 is triggered either by an overflow condition
or by a negative/positive edge (chosen by the bit EDGESEL in register T2MOD) at input
pin T2EX. If an overflow caused the reload, the overflow flag TF2 is set. If a
*
Содержание XC886CLM
Страница 1: ...User s Manual V1 3 2010 02 Microcontrollers 8 Bit XC886 888CLM 8 Bit Single Chip Microcontroller...
Страница 3: ...User s Manual V1 3 2010 02 Microcontrollers 8 Bit XC886 888CLM 8 Bit Single Chip Microcontroller...
Страница 324: ...XC886 888CLM Serial Interfaces User s Manual 12 52 V1 3 2010 02 Serial Interfaces V 1 0...
Страница 663: ...w w w i n f i n e o n c o m Published by Infineon Technologies AG...