Preliminary
...the world's most energy friendly microcontrollers
2011-05-19 - d0034_Rev0.91
146
www.energymicro.com
When a slave receives a 10-bit address, it must acknowledge both the address bytes if they match the
address of the slave.
When performing a master transmitter operation, the master transmits the two address bytes and then
Figure 14.8. I
2
C Master Transmitter/Slave Receiver with 10-bit Address
W
S
A
DATA
A
P
Addr (2nd byt e)
ADDR (1st 7 bit s)
When performing a master receiver operation however, the master first transmits the two address bytes
in a master transmitter operation, then sends a repeated START followed by the first address byte and
then receives data from the addressed slave. The slave addressed by the 10-bit address in the first two
address bytes must remember that it was addressed, and respond with data if the address transmitted
after the repeated start matches its own address. An example of this, with one byte transmitted is shown
Figure 14.9. I
2
C Master Receiver/Slave Transmitter with 10-bit Address
R
Sr
DATA
A
N
P
W
S
A
ADDR (1st 7 bit s)
Addr (2nd byt e)
ADDR (1st 7 bit s)
14.3.1.5 Arbitration, Clock Synchronization, Clock Stretching
Arbitration and clock synchronization are features aimed at allowing multi-master buses. Arbitration
occurs when two devices try to drive the bus at the same time. If one device drives it low, while the
other drives it high, the one attempting to drive it high will not be able to do so due to the open-drain
bus configuration. Both devices sample the bus, and the one that was unable to drive the bus in the
desired direction detects the collision and backs off, letting the other device continue communication
on the bus undisturbed.
Clock synchronization is a means of synchronizing the clock outputs from several masters driving the
bus at once, and is a requirement for effective arbitration.
Slaves on the bus are allowed to force the clock output on the bus low in order to pause the
communication on the bus and give themselves time to process data or perform any real-time tasks they
might have. This is called clock stretching.
Arbitration is supported by the I
2C module for both masters and slaves. Clock synchronization and clock
stretching is also supported.
14.3.2 Enable and Reset
The I
2C is enabled by setting the EN bit in the I2Cn_CTRL register. Whenever this bit is cleared, the
internal state of the I
2C is reset, terminating any ongoing transfers.
Note
When re-enabling the I
2C, the ABORT command or the Bus Idle Timeout feature must be
applied prior to use even if the BUSY flag is not set.
14.3.3 Safely disabling and changing slave configuration
The I
2C slave is partially asynchronous, and some precautions may be necessary to always ensure a
safe slave disable or configuration change. If the user cannot guarantee that an address match will not
occur at the exact time of slave disable or slave configuration change while the slave is enabled, these
measures should be taken.
Worst case consequences for an address match while disabling slave or changing configuration is that
the slave may end up in an undefined state. To reset the slave back to a known state, the EN bit in