mg84fl54b Megawin Technology, mg84fl54b Datasheet - Page 29

no-image

mg84fl54b

Manufacturer Part Number
mg84fl54b
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
10.2.4. Programmable Clock Output from Timer 2
Timer 2 has a Clock-Out Mode (while CP/-RL2=0 & T2OE=1). In this mode, Timer 2 operates as a
programmable clock generator with 50% duty-cycle. The generated clocks come out on P1.0. The input clock,
Fosc/2, increments the 16-bit timer [TH2, TL2], where Fosc is the system clock. The timer repeatedly counts to
overflow from a loaded value. Once overflows occur, the contents of [RCAP2H, RCAP2L] are loaded into [TH2,
TL2] for the consecutive counting. Note that the Timer 2 overflow flag, TF2, will always not be set in this mode.
The following formula gives the clock-out frequency:
Fosc
=
Clock
-
out
Frequency
4
x
(65536
-
[RCPA2H,
RCAP2L])
(For a 12 MHz system clock, Timer 2 has a programmable output frequency range of 45.7 Hz to 3 MHz.)
How to Program Timer 2 as Its Clock-out Mode
• Set T2OE bit in T2MOD register.
• Clear C/T2 bit in T2CON register.
• Determine the 16-bit reload value from the formula and enter it in the [RCAP2H, RCAP2L] registers.
• Enter the same reload value as the initial value in the [TH2, TL2] registers.
• Set TR2 bit in T2CON register to start the Timer 2.
In the Clock-Out mode, Timer 2 rollovers will not generate an interrupt. This is similar to when Timer 2 is used
as a baud-rate generator. It is possible to use Timer 2 as a baud rate generator and a clock generator
simultaneously. Note, however, in this configuration, the baud rates and clock frequencies are not independent
since both functions use the same reload values in the [RCAP2H, RCAP2L] registers.
MEGAWIN
MG84FL54B Data sheet
29

Related parts for mg84fl54b