Section 17 I2C Bus Interface 2 (IIC2)
Start
Initialize
[1] Test the status of the SCL and SDA lines.
[2] Set master transmit mode.
Read BBSY in ICCR2
[1]
No
BBSY=0 ?
[3] Issue the start candition.
Yes
Set MST and TRS
in ICCR1 to 1.
[4] Set the first byte (slave address + R/W) of transmit data.
[5] Wait for 1 byte to be transmitted.
[6] Test the acknowledge transferred from the specified slave device.
[7] Set the second and subsequent bytes (except for the final byte) of transmit data.
[8] Wait for ICDRT empty.
[2]
[3]
[4]
Write 1 to BBSY
and 0 to SCP.
Write transmit data
in ICDRT
Read TEND in ICSR
[5]
[6]
No
TEND=1 ?
Yes
[9] Set the last byte of transmit data.
[10] Wait for last byte to be transmitted.
[11] Clear the TEND flag.
Read ACKBR in ICIER
No
ACKBR=0 ?
Yes
No
Transmit
mode?
Mater receive mode
Yes
[12] Clear the STOP flag.
[7]
[8]
Write transmit data in ICDRT
[13] Issue the stop condition.
Read TDRE in ICSR
No
[14] Wait for the creation of stop condition.
[15] Set slave receive mode. Clear TDRE.
TDRE=1 ?
Yes
No
Last byte?
[9]
Yes
Write transmit data in ICDRT
Read TEND in ICSR
[10]
No
TEND=1 ?
Yes
[11]
[12]
Clear TEND in ICSR
Clear STOP in ICSR
Write 0 to BBSY
and SCP
[13]
Read STOP in ICSR
[14]
No
STOP=1 ?
Yes
Set MST to 1 and TRS
to 0 in ICCR1
[15]
Clear TDRE in ICSR
End
Figure 17.17 Sample Flowchart for Master Transmit Mode
Rev. 3.00 Sep. 10, 2007 Page 358 of 528
REJ09B0216-0300