mg84fl54 Megawin Technology, mg84fl54 Datasheet - Page 37

no-image

mg84fl54

Manufacturer Part Number
mg84fl54
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
11.2.3. Baud-Rate Generator Mode (BRG)
Bits TCLK and/or RCLK in T2CON register allow the serial port transmit and receive baud rates to be derived
from either Timer 1 or Timer 2. When TCLK=0, Timer 1 is used as the serial port transmit baud rate generator.
When TCLK= 1, Timer 2 is used as the serial port transmit baud rate generator. RCLK has the same effect for
the serial port receive baud rate. With these two bits, the serial port can have different receive and transmit
baud rates – one generated by Timer 1, the other by Timer 2.
Fig 11-8 shows the Timer 2 in baud rate generation mode to generate RX Clock and TX Clock into UART
engine (See Fig 12-6 ). The baud rate generation mode is like the auto-reload mode, in that a rollover in TH2
causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are
preset by firmware.
The Timer 2 as a baud rate generator mode is valid only if RCLK and/or TCLK=1 in T2CON register. Note that a
rollover in TH2 does not set TF2, and will not generate an interrupt. Thus, the Timer 2 interrupt does not have to
be disabled when Timer 2 is in the baud rate generator mode. Also if the EXEN2 (T2 external enable bit) is set,
a 1-to-0 transition in T2EX (Timer/counter 2 trigger input) will set EXF2 (T2 external flag) but will not cause a
reload from (RCAP2H, RCAP2L) to (TH2,TL2). Therefore when Timer 2 is in use as a baud rate generator,
T2EX can be used as an additional external interrupt, if needed.
When Timer 2 is in the baud rate generator mode, one should not try to read or write TH2 and TL2. As a baud
rate generator, Timer 2 is incremented at 1/2 the system clock or asynchronously from pin T2; under these
conditions, a read or write of TH2 or TL2 may not be accurate. The RCAP2 registers may be read, but should
not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should
be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.
Note:
Fig 11-8 Timer 2 in Baud-Rate Generator Mode
MEGAWIN
Refer to
rate generator.
SYSCLK
T2 Pin
T2EX Pin
12.7.3 Baud Rate in Mode 1 & 3
2
Transition
Detection
C//T2=0
C//T2=1
EXEN2
TR2
MG84FL54B Data sheet
to get baud rate setting value when using Timer 2 as the baud
RCAP2L
(8 Bits)
TL2
EXF2
RCAP2H
(8 Bits)
TH2
Reload
Timer2 Interrupt
“1”
“1”
“0”
“0”
“0”
2
Overflow
Timer 1
“1”
SMOD
RCLK
TCLK
RX Clock
TX Clock
37

Related parts for mg84fl54