Texas Instruments MSC1210 User Manual
Page 270
Serial Port I/O
17-42
17.13.1
Serial Port 0 Operation Mode 1 Example
void show_baud_gen (void)
{
P3DDRL &= 0xf0;
P3DDRL |= 0x07;
//P30 input, P31 output
TF2 = CLEAR; T2 = CLEAR;
CKCON |= 0x30;
// Set timer 2 to clk/4
RCAP2 = 0xFF16; //37500 bps
THL2=0xFFFF;
/* Set T2 for Serial0 Tx baudgen.
Timer 2 is designated the clock source for the ”divide by 16” clock
for the Transmit block, while Timer 1 is the implied source for the
”divide by 16” clock for the Receive block.
TR2 is activated*/
T2CON = 0x14;
//SCON: Async mode 1, 8−bit UART, enable rcvr; TI=CLEAR, RI = CLEAR
SCON = 0x50;
PCON |= 0x80; // Set SMOD0 for 16X baud rate clock
//set Timer 1 up for Rx Baud Rate Generation @ 37500 bps
TH1 = 0xF6;
/*Make the Timer 1 clocking Gated. This implies that for the Timer 1 to
run, both TR1 and INT1# must be set.*/
TMOD = 0xA0;
TCON = 0x48;
//
TI=SET;
}