18 UNIVERSAL SERIAL INTERFACE (USI)
18-12
Seiko Epson Corporation
S1C33L26 TECHNICAL MANUAL
Slave address
7-bit address
Transfer direction
0: master
→
slave (transmission)
1: slave
→
master (reception)
A6
A5
D7
D6
A4
D5
A3
D4
A2
D3
A1
D2
A0
D1
R/W
D0
8 low order slave address bits
A7
A6
D7
D6
A5
D5
A4
D4
A3
D3
A2
D2
A1
D1
A0
D0
2 high order
slave address bits
10-bit address
1
First transmit data
Second transmit data
Third transmit data
1
D7
D6
1
D5
1
D4
0
D3
A9
D2
A8
D1
0
D0
1
1
D7
D6
1
D5
1
D4
0
D3
A9
D2
A8
D1
1
D0
When the I
2
C master performs data reception, issue a repeated start condition after the second data
has been sent and then send the third data as shown below.
2 high order
slave address bits
5.3.4 Transmit Data Specifying Slave Address and Transfer Direction
Figure 18.
The transfer direction bit indicates the data transfer direction after the slave address has been sent. Set this
bit to 0 when sending data from the master to the slave.
To send a slave address, set the address with the transfer direction bit to the transmit data buffer (TD[7:0]/
USI_TD register). Then set IMTGMOD[2:0] to 0x2 and write 1 to IMTG.
To send a 10-bit address, execute this procedure twice or three times as shown in Figure 18.5.3.4.
Writing 1 to IMTG sets IMBSY to 1. When data in the transmit data buffer is sent to the transmit shift reg-
ister, IMBSY reverts to 0 and IMSTA[2:0] is set to 0x2. Confirm that the slave address (each byte) has been
sent by reading IMBSY or using an interrupt.
After a slave address has been sent, the selected slave device sends back an ACK by pulling down the SCL
line to low. If the SCL line maintains high, it is regarded as a NAK. In this case, the I
2
C controller cannot
communicate with the slave device specified.
SDA (USI_DI) (output)
SDA (USI_DI) (input)
SCL (USI_CK)
Start condition
1
2
8
9
D7
D6
D0
ACK
NAK
5.3.5 ACK and NAK
Figure 18.
It is necessary to check that an ACK has been received before sending data. To do this, set IMTGMOD[2:0]
to 0x6 and write 1 to IMTG after the slave address has been sent.
IMBSY is set to 1 while an ACK/NAK is being detected and it reverts to 0 when the detection has com-
pleted. Receiving an ACK sets IMSTA[2:0] to 0x5; receiving a NAK sets it to 0x6. Check IMSTA[2:0]
after confirming IMBSY or using an interrupt. When an ACK has been received, perform data transmission.
When a NAK has been received, perform an error handling.
(3) Data transmission
The data transmission procedure is the same as that of the slave address transmission.
1. Write an 8-bit transmit data to the transmit data buffer (TD[7:0]).
2. Set IMTGMOD[2:0] to 0x2 and IMTG to 1.
This trigger transfers the buffer data to the transmit shift register to start transmission. The module starts
clock output from the USI_CK pin. The data in the shift register is shifted in sequence with the clock and
sent from the USI_DO pin.