18 UNIVERSAL SERIAL INTERFACE (USI)
S1C33L26 TECHNICAL MANUAL
Seiko Epson Corporation
18-7
Data Transfer Control
18.5
This section describes how to control data transfers. The following explanations assume that the configurations de-
scribed above and interrupt/DMA settings have already been finished.
Data Transfer in UART Mode
18.5.1
Data transmission
To start data transmission in UART mode, write the transmit data to the transmit data buffer (TD[7:0]/USI_TD
register).
The buffer data is sent to the transmit shift register, and the start bit is output from the USI_DO pin. The data
in the shift register is then output in sequence. Following output of the eighth data bit, the parity bit (if parity is
enabled) and the stop bit are output.
The transmitter circuit includes two status flags: UTDIF/USI_UIF register and UTBSY/USI_UIF register.
The UTDIF flag indicates the transmit data buffer status. This flag is set to 1 indicating that the transmit data
buffer becomes empty when data written to the transmit data buffer is sent to the transmit shift register. UTDIF
is an interrupt flag. An interrupt or DMA request can be generated when this flag is set to 1 (see Section 18.7).
Write subsequent data to the transmit data buffer to start the following transmission using this interrupt or
DMA. The transmit data buffer size is 1 byte, but a shift register is provided separately to allow data to be writ-
ten while the previous data is being sent. If an interrupt or DMA is not used for transmission, be sure to confirm
that the transmit data buffer is empty before writing transmit data. Writing data before UTDIF has been set will
overwrite earlier transmit data inside the transmit data buffer. After UTDIF is set to 1, it can be reset to 0 by
writing 1.
The UTBSY flag indicates the USI status in UART mode. This flag switches to 1 when transmit data is written
to the transmit buffer and reverts to 0 after both the shift register and transmit buffer become empty.
Sampling clock
TD[7:0]
Shift register
USI_DO pin
UTDIF
UTBSY
Interrupt
start
stop
stop
A
D7
A
D6
A
D5
A
D4
A
D3
A
D2
A
D1
A
D0
parity
parity
B
D0
Write
Write
Transmit buffer empty interrupt
Reset by writing 1
Reset by writing 1
Transmit buffer empty interrupt
(MSB first)
Data A
Data B
start B
D7
B
D6
5.1.1 Data Transmission Timing Chart (UART mode)
Figure 18.
Data reception
When the external serial device sends a start bit, the receiver circuit detects its low level and starts sampling the
following data bits. Once the 8-bit data has been received into the shift register, the received data is loaded into
the receive data buffer (RD[7:0]/USI_RD register). If parity checking is enabled, the receiver circuit checks the
received data at the same time by checking the parity bit received immediately after the eighth data bit.
The receiver circuit includes two status flags: URDIF/USI_UIF register and URBSY/USI_UIF register.
The URDIF flag indicates the receive data buffer status. This flag is set to 1 indicating that the received data can
be read out when data received in the shift register is loaded to the receive data buffer. URDIF is an interrupt
flag. An interrupt or DMA request can be generated when this flag is set to 1 (see Section 18.7). Read the
received data from the receive data buffer using this interrupt or DMA. The receive data buffer size is 1 byte,
therefore the received data must be read before the subsequent data reception has completed. Furthermore,
URDIF must be reset by writing 1. If the next reception is completed when URDIF is 1 and the receive data
buffer (USI_RD register) is not read, an overrun error occurs (at the time stop bit has been received).
The URBSY flag indicates the shift register status. This flag is set to 1 while data is being received in the shift
register and reverts to 0 once the received data is loaded to the receive data buffer. Read this flag to check
whether the receiver circuit is operating or at standby.