beautypg.com

3 16-bit auto-reload timer/counter, Imer, Odes – Maxim Integrated High-Speed Microcontroller User Manual

Page 127: Bit timer/counter, Bit timer with capture, Figure 11-4. timer/counter 2 with optional capture

background image

High-Speed Microcontroller User’s Guide

Rev: 062210

127 of 176

11.7.3

16-Bit Auto-Reload Timer/Counter

This mode is illustrated in

Figure 11-5

. When Timer 2 reaches an overflow state, i.e., rolls over from

FFFFh to 0000h, it will set the TF2 Flag. This flag can generate an interrupt if enabled. In addition, the
timer will restore its starting value and begin timing (or counting) again. The starting value is preloaded
by software into the capture registers RCAP2L and RCAP2H. These registers cannot be used for capture
functions while also performing auto-reload, so these modes are mutually exclusive. Auto-reload is
invoked by the CP/

RL2

(

T2CON

.0) bit. When set to logic 0, the timer is in auto-reload mode. When

CP/

RL2

is set to a logic 1, the timer is in capture mode described above. If the oscillator time base is used

(C/

T2

=

T2CON

.1 = 0), the timer’s input may be selected to be oscillator cycles divided by either 12 or 4

as determined by T2M (

CKCON

.5). Otherwise, pulses on pin T2 (P1.0) are counted when C/

T2

= 1. As

in other modes, Counting or timing is enabled or disabled with TR2 (

T2CON

.2).


When in auto-reload mode, Timer 2 can also be forced to reload with the T2EX (P1.1) pin. A 1-to-0
transition will force a reload if enabled by the EXEN2 (

T2CON

.3) bit. If EXEN2 is set to logic 1, then a

1-to-0 transition on T2EX will cause a reload. Otherwise, the T2EX pin will be ignored.