
20 I2C Master (I2CM)
S1C17003 TECHNICAL MANUAL
EPSON
20-7
I2CM
Data receipt control
The procedure for receiving data is described below. To receive data, the slave address must be sent with the
transfer direction bit set to 1.
To receive data, set RXE (D10/I2C_DAT register) to 1 for receiving 1 byte.
TXE (D9/I2C_DAT register) is set to 1 when sending the slave address, but RXE can also be set to 1 at the
same time. If both TXE and RXE are set to 1, TXE takes priority.
RXE: Receive Execution Bit in the I2C Data (I2C_DAT) Register (D10/0x4344)
When the RXE bit is set to 1, allowing receiving to start, the I2C master module starts outputting the clock from
the SCL0 pin with the SDA line at high impedance. The data is loaded to the shift register in sequence at the
clock rising edge, with the MSB leading.
RXE is reset to 0 when D6 is loaded.
The receive data is loaded to RTDT[7:0] once the 8-bit data has been received in the shift register. The I2C
master module includes two status bits for receive control: RBRDY (D11/I2C_DAT register) and RBUSY (D9/
I2C_CTL register).
RBRDY: Receive Buffer Ready Bit in the I2C Data (I2C_DAT) Register (D11/0x4344)
RBUSY: Receive Busy Flag in the I2C Control (I2C_CTL) Register (D9/0x4342)
The RBRDY flag indicates the receive data status. This flag becomes 1 when the data received in the shift
register is loaded to RTDT[7:0] and reverts to 0 when the receive data is read out from RTDT[7:0]. Interrupts
can also be generated once the flag value becomes 1.
The RBUSY flag indicates the receiving operation status. This flag is 1 when receiving starts and reverts to 0
when the data is received. It also reverts to 0 for the Wait state. Inspect the flag to determine whether the I2C
master module is currently receiving or in standby.
To wait for reception using polling, follow the procedures given below using the RBUSY flag.
Interrupts to the CPU are prohibited because polling accurately determines the two state transitions 3 and 4.
1. Prohibits CPU interrupts using di instruction.
2. Writes 1 to RXE to prepare for receiving.
3. Waits for RBUSY to become 1 (reception start).
4. Waits for RBUSY to become 0 (reception end).
5. Reads out RTDT (received data).
6. Returns to CPU interrupt permitted state using ei instruction.
The I2C master module outputs 9 clocks with each data receipt. In the 9th clock cycle, an ACK or NACK is sent
to the slave from the SDA0 pin. The bit state sent can be set in RTACK (D8/I2C_DAT register). To send ACK,
set RTACK to 0. To send NACK, set RTACK to 1.
Data transfer end (Stop condition generation)
To end data transfers after all data has been transferred, the I2C master (this module) must generate a stop
condition. This stop condition applies when the SCL line is maintained at High and the SDA line changes from
Low to High.
SDA0 (output)
SCL0 (output)
Stop condition
Figure 20.5.4: Stop condition
The stop condition is generated by setting STP (D1/I2C_CTL register) to 1.
STP: Stop Control Bit in the I2C Control (I2C_CTL) Register (D1/0x4342)
When STP is set to 1, the I2C master module switches the SDA line from Low to High and generates a stop
condition while maintaining the I2C bus SCL line at High. The I2C bus subsequently switches to free state.
Stop condition generation can be reserved. To reserve the stop condition, check that I2C master module is
operating (TBUSY = 1 or RBUSY = 1), and then set STP to 1.
The stop condition is generated as soon as data transfer (including ACK transfer) ends. STP is reset to 0 when
the stop condition is generated.