The protocol of the I2C bus defines
two states to begin and end a transaction: START and STOP(see Figure 19-5).
A High-to-Low transition on the SDA line while the SCL is High is defined as a
START condition, and a Low-to-High transition on the SDA line while SCL is
High is defined as a
STOP condition. START and STOP conditions are always
generated by the master. The bus is considered busy after a START condition and free
after a STOP condition.
Note: The Target
mode logic should be designed to handle abrupt START and STOP conditions on the bus.
- In case of an unexpected
STOP, the logic must go back to IDLE state and wait for the next START
- In case of an unexpected
START, the logic must check for address on the bus
The STOP bit
determines if the transaction stops at the end of the data cycle or continues on to
a repeated START condition.
To generate a single transaction:
- I2C Controller target address (CSA) register is written with the desired address
- DIR bit is cleared to ‘0’
- Control register CCTR is written with ACK = X (0 or 1), STOP = 1, START = 1, and
BURSTRUN = 1 to perform the operation and stop
- When the operation is completed (or aborted due an error) the interrupt flag(s)
are set.
Note:
- ACK bit only controls the ACK
of last byte of MBLEN transfer. All other bytes are auto-ACKed by hardware.
- The details of all memory
mapped registers of the IP can be found in Section 19.6.
When the I2C module operates in
Controller receiver mode, the ACK bit is normally (in case of no error) set causing
the I2C bus controller to transmit an acknowledge automatically after each byte.
This bit must be cleared when the I2C bus controller requires no further data to be
transmitted from the Target transmitter i.e. after the last byte of transfer and
then immediately generate the STOP bit.