
Start
Initialize
Read BBSY in ICCR2
BBSY=0?
Set MST and TRS in
ICCR1 to 1
Write 1 to BBSY
and 0 to SCP
Write transmit data
in ICDRT
TEND= 1?
Read TEND in ICSR
No
Yes
Yes
Read ACKBR in ICIER
ACKBR=0?
Transmit
mode?
Mater receive mode
No
Yes
Write transmit data
in ICDRT
Yes
TEND=1 ?
Read TEND in ICSR
No
Write 0 to BBSY
and SCP
Yes
STOP=1?
Read STOP in ICSR
Set MST and TRS
in ICCR1 to 0
End
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
Clear TDRE in ICSR
[11]
[12]
[13]
[1] Test the status of the SCL and SDA lines.
[2] Set master transmit mode.
[3] Issue the start condition.
[4] Wait for the SCL=0 output.
[5] Set the first byte (slave address + R/W) of
transmit data.
[6] Wait for 1 byte to be transmitted.
[7] Clear the TEND flag.
[8] Test the acknowledge transferred from the
specified slave device.
[9] Wait for the SCL=0 output.
[10] Set the second and subsequent bytes of transmit
data.
[11] Wait for the completion of transmission.
[12] Clear the TEND flag.
[13] Test the acknowledge.
[14] Test the last byte.
[15] Clear the STOP flag.
[16] Issue the stop condition.
[17] Wait for the creation of stop condition.
[18] Set slave receive mode.
[19] Clear the TDRE flag.
Clear TEND in ICSR
[14]
SCLO=0?
No
Yes
Read SCLO in ICCR2
No
No
Read SCLO in ICCR2
SCLO=0?
Last byte?
Clear STOP in ICSR
No
No
No
Yes
Yes
Yes
[10]
Clear TEND in ICSR
Read ACKBR in ICIER
ACKBR=0?
No
Yes
A
A
[15]
[16]
[17]
[19]
[18]
Figure 2-4 Sample Flowchart for Master Transmit Mode
Kommentare zu diesen Handbüchern