Inter-integrated circuit (I
2
C) interface
RM0090
842/1731
DocID018909 Rev 11
For N >2 -byte reception, from N-2 data reception
•
Wait until BTF = 1 (data N-2 in DR, data N-1 in shift register, SCL stretched low until
data N-2 is read)
•
Set ACK low
•
Read data N-2
•
Wait until BTF = 1 (data N-1 in DR, data N in shift register, SCL stretched low until a
data N-1 is read)
•
Set STOP high
•
Read data N-1 and N
27.3.4 Error
conditions
The following are the error conditions which may cause communication to fail.
Bus error (BERR)
This error occurs when the I
2
C interface detects an external Stop or Start condition during
an address or a data transfer. In this case:
•
the BERR bit is set and an interrupt is generated if the ITERREN bit is set
•
in Slave mode: data are discarded and the lines are released by hardware:
–
in case of a misplaced Start, the slave considers it is a restart and waits for an
address, or a Stop condition
–
in case of a misplaced Stop, the slave behaves like for a Stop condition and the
lines are released by hardware
•
In Master mode: the lines are not released and the state of the current transmission is
not affected. It is up to the software to abort or not the current transmission
Acknowledge failure (AF)
This error occurs when the interface detects a nonacknowledge bit. In this case:
•
the AF bit is set and an interrupt is generated if the ITERREN bit is set
•
a transmitter which receives a NACK must reset the communication:
–
If Slave: lines are released by hardware
–
If Master: a Stop or repeated Start condition must be generated by software
Arbitration lost (ARLO)
This error occurs when the I
2
C interface detects an arbitration lost condition. In this case,
•
the ARLO bit is set by hardware (and an interrupt is generated if the ITERREN bit is
set)
•
the I
2
C Interface goes automatically back to slave mode (the MSL bit is cleared). When
the I
2
C loses the arbitration, it is not able to acknowledge its slave address in the same
transfer, but it can acknowledge it after a repeated Start from the winning master.
•
lines are released by hardware