English
Language : 

H836912 Datasheet, PDF (294/440 Pages) Renesas Technology Corp – Renesas 16-Bit Single-Chip Microcomputer H8 Family / H8/300H Tiny Series
Section 15 I2C Bus Interface 2 (IIC2)
15.4.8 Example of Use
Flowcharts in respective modes that use the I2C bus interface are shown in figures 15.17 to 15.20.
Start
Initialize
[1] Test the status of the SCL and SDA lines.
Read BBSY in ICCR2
No
BBSY=0 ?
Yes
Set MST and TRS
in ICCR1 to 1.
Write 1 to BBSY
and 0 to SCP.
Write transmit data
in ICDRT
Read TEND in ICSR
No
TEND=1 ?
Yes
Read ACKBR in ICIER
ACKBR=0 ?
No
Yes
Transmit
No
mode?
Yes
Write transmit data in ICDRT
[2] Set master transmit mode.
[1]
[3] Issue the start candition.
[2] [4] Set the first byte (slave address + R/W) of transmit data.
[3] [5] Wait for 1 byte to be transmitted.
[4] [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.
[5] [8] Wait for ICDRT empty.
[9] Set the last byte of transmit data.
[6] [10] Wait for last byte to be transmitted.
[11] Clear the TEND flag.
Mater receive mode
[7] [12] Clear the STOP flag.
Read TDRE in ICSR
No
TDRE=1 ?
Yes
No
Last byte?
Yes
Write transmit data in ICDRT
[13] Issue the stop condition.
[8]
[14] Wait for the creation of stop condition.
[15] Set slave receive mode. Clear TDRE.
[9]
Read TEND in ICSR
No
TEND=1 ?
[10]
Yes
Clear TEND in ICSR
[11]
Clear STOP in ICSR
[12]
Write 0 to BBSY
[13]
and SCP
Read STOP in ICSR
No
STOP=1 ?
[14]
Yes
Set MST to 1 and TRS
to 0 in ICCR1
[15]
Clear TDRE in ICSR
End
Figure 15.17 Sample Flowchart for Master Transmit Mode
Rev. 3.00 Sep. 14, 2006 Page 266 of 408
REJ09B0105-0300