Chapter 13
Serial Interface 2
Operation XIII - 33
13.3.5 Setup Example
■ UART Serial Interface Setup Example
The setup example of UART transmission/reception with serial interface 2 is shown. Table: 13.3.14 shows the
conditions for transmission/reception.
Table:13.3.15 Condition of UART Interface Transmission/Reception
An example setup procedure, with a description of each step is shown below.
Setting item Description
SBI2/SBO2 pin setting Independent (2 channels)
Frame mode specification
8 bit + 2 stop bits
First transfer bit MSB
Clock source Timer 14
Parity bit add/check "0" added/check
Serial 2 transmission complete interrupt Enabled
Serial 2 reception complete interrupt Enabled
Setup Procedure Description
(1) Set the baud rate timer (1) Set the baud rate by the TM14MD and TM14BR
registers and set the TM4EN flag to “1” to operate the
timer 14.
(2) Select the baud rate timer
SIFCLK(0x0000A10E)
bp5-4: SC2CKS2-1=00
(2) Set the SC2CKS2-1 flags of the SIFCLK register to “00”
to set the timer 14 underflow to the baud rate timer.
(3) Select the clock source
SC2CTR3(0x0000A125)
bp2-0: SC2PSC2-0=000
(3) Set the SC2PSC2-0 flags of the SC2CTR3 register to
“000” to select 1/32 of timer underflow.
(4) Set the pin function
P1MD(0x0000A031)
bp7: P17M=1
(4) Set the P17M flag of the P1MD register to “1” to set it to
the SBO2 pin function.
(5) Control the pin direction
P1DIR(0x0000A021)
bp7: P17D=1
P2DIR(0x0000A022)
bp1: P21D=0
(5) Set the P17D flag of the P1DIR register to “1” to set
P17(SBO2 pin ) to the output pin; and set the P21D
flag of the P2DIR register to “0” to set P21(SBI2) to the
input pin.
(6) Set the SC2CTR0 register
Select the start condition
SC2CTR0(0x0000A120)
bp3: SC2STE=1
Select the first transfer bit
SC2CTR0(0x0000A120)
bp4: SC2DIR=0
(6) Set the SC2STE flag of the SC2CTR0 register to “1” and
select “With start condition”.
Set the SC2DIR flag of the SC2CTR0 register to “0” to
set the first transfer bit to MSB.