English
Language : 

MG82FX564AE Datasheet, PDF (56/151 Pages) Megawin Technology Co., Ltd – Dual data pointer
11.2.3. Baud-Rate Generator Mode (BRG) Structure
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:
Refer to 12.7.3 Baud Rate in Mode 1 & 3 to get baud rate setting value when using Timer 2 as the baud rate
generator.
Fig 11-8 Timer 2 in Baud-Rate Generator Mode
Timer 1
Overflow
SYSCLK
¸2
C/T2=0
T2 Pin
C/T2=1
TR2
T2EX Pin
Transition
Detection
EXEN2
¸2
“0” “1”
TL2
(8 Bits)
TH2
(8 Bits)
Reload
RCAP2L RCAP2H
“1” “0”
“1” “0”
EXF2
Timer2 Interrupt
SMOD1
RCLK
RX Clock
TCLK
TX Clock
56
MG82FEL564 Data Sheet
MEGAWIN