EasyManuals Logo

Atmel 8051 User Manual

Atmel 8051
113 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #88 background imageLoading...
Page #88 background image
Common Features Description
2-87 Atmel 8051 Microcontrollers Hardware Manual
4316B–8051–02/04
but with the added feature that a 1-to-0 transition at external input T2EX will also trigger
the 16-bit reload and set EXF2.
2.12.1 Auto-reload Mode The auto-reload mode configures timer 2 as a 16-bit timer or event counter with auto-
matic reload. This feature is controlled by the DCEN bit in the T2MOD register (See
Table 2-9). Setting the DCEN bit enables timer 2 to count up or down as shown in Fig-
ure 2-17. In this mode the T2EX pin controls the counting direction.
When T2EX is high, timer 2 up-counts. Timer overflow occurs at FFFFh which sets the
TF2 flag and generates an interrupt request. The overflow also causes the 16-bit value
in the RCAP2H and RCAP2L registers to be loaded into the timer registers TH2 and
TL2.
When T2EX is low, timer 2 down-counts. Timer underflow occurs when the count in the
timer registers, TH2 and TL2, equals the value stored in the RCAP2H and RCAP2L reg-
isters. The underflow sets TF2 flag and reloads FFFFh into the timer registers.
The EXF2 bit toggles when timer 2 overflow or underflow occurs, depending on the
direction of the count. EXF2 does not generate an interrupt. This bit can be used to pro-
vide 17-bit resolution.
Figure 2-17. Auto-reload Mode Up/Down Counter
2.12.2 Programmable
Clock-output
In clock-out mode, timer 2 operates as a 50% duty-cycle, programmable clock generator
(See Figure 2-18). The input clock increments TL2 at frequency F
OSC
/2. The timer
repeatedly counts to overflow from a loaded value. At overflow, the contents of the
RCAP2H and RCAP2L registers are loaded into TH2 and TL2. In this mode, timer 2
overflows do not generate interrupts. The formula gives the clock-out frequency,
(DOWN COUNTING RELOAD VALUE)
TF2
T2
EXF2
TH2
(8-bit)
TL2
(
8-bit)
RCAP2H
(8-bit)
RCAP2L
(8-bit)
FFh
(8-bit)
FFh
(8-bit)
TOGGLE
(UP COUNTING RELOAD VALUE)
TIMER 2
INTERRUPT
:6
T2CONreg
T2CONreg
T2EX:
1=UP
2=DOWN
0
1
CT/2
T2CON.1
TR2
T2CON.2
Periph
CLOCK

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Atmel 8051 and is the answer not in the manual?

Atmel 8051 Specifications

General IconGeneral
BrandAtmel
Model8051
CategoryMicrocontrollers
LanguageEnglish

Related product manuals