10 UART (UART)
10-4
Seiko epson Corporation
S1C17F13 TeChniCal Manual
(Rev. 1.0)
UA
n
MOD register
PREN bit
0
1
0
1
0
1
0
1
STPB bit
0
0
1
1
0
0
1
1
CHLN bit
0
0
0
0
1
1
1
1
st: start bit, sp: stop bit, p: parity bit
st
D0
D1
D2
D3
D4
D5
D6
sp
st
D0
D1
D2
D3
D4
D5
D6
p
sp
st
D0
D1
D2
D3
D4
D5
D6
sp
sp
st
D0
D1
D2
D3
D4
D5
D6
p
sp
sp
st
D0
D1
D2
D3
D4
D5
D6
D7
sp
st
D0
D1
D2
D3
D4
D5
D6
D7
p
sp
st
D0
D1
D2
D3
D4
D5
D6
D7
sp
sp
st
D0
D1
D2
D3
D4
D5
D6
D7
p
sp
sp
4.1 Data Format
Figure 10.
Operations
10.5
Initialization
10.5.1
The UART Ch.
n
should be initialized with the procedure shown below.
1. Assign the UART Ch.
n
input/output function to the ports. (Refer to the “I/O Ports” chapter.)
2. Set the UA
n
CLK.CLKSRC[1:0] and UA
n
CLK.CLKDIV[1:0] bits. (Configure operating clock)
3. Configure the following UA
n
MOD register bits:
- UA
n
MOD.PUEN bit
(Enable/disable USIN
n
pin pull-up)
- UA
n
MOD.OUTMD bit (Enable/disable USOUT
n
pin open-drain output)
- UA
n
MOD.IRMD bit
(Enable/disable IrDA interface)
- UA
n
MOD.CHLN bit
(Set 7/8-bit data length)
- UA
n
MOD.PREN bit
(Enable/disable parity function)
- UA
n
MOD.PRMD bit
(Even/odd parity selection)
- UA
n
MOD.STPB bit
(Set 1/2-bit stop bit length)
4. Set the UA
n
BR.BRT[7:0] and UA
n
BR.FMD[3:0] bits.
(Set transfer rate)
5. Set the following UA
n
CTL register bits:
- Set the UA
n
CTL.SFTRST bit to 1.
(Execute software reset)
- Set the UA
n
CTL.MODEN bit to 1.
(Enable UART Ch.
n
operations)
6. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the UA
n
INTF register.
(Clear interrupt flags)
- Set the interrupt enable bits in the UA
n
INTE register to 1. * (Enable interrupts)
*
The initial value of the UA
n
INTF.TBEIF bit is 1, therefore, an interrupt will occur immediately after the
UA
n
INTE.TBEIE bit is set to 1.
Data Transmission
10.5.2
A data sending procedure and the UART Ch.
n
operations are shown below. Figures 10.5.2.1 and 10.5.2.2 show a
timing chart and a flowchart, respectively.
Data sending procedure
1. Check to see if the UA
n
INTF.TBEIF bit is set to 1 (transmit buffer empty).
2. Write transmit data to the UA
n
TXD register.
3. Wait for a UART interrupt when using the interrupt.
4. Repeat Steps 1 to 3 (or 1 and 2) until the end of transmit data.