270
8331B–AVR–03/12
Atmel AVR XMEGA AU
When an interrupt flag is set, the SCL line is forced low. This will give the master time to respond
or handle any data, and will in most cases require software interaction.
shows the
TWI master operation. The diamond shaped symbols (SW) indicate where software interaction
is required. Clearing the interrupt flags releases the SCL line.
Figure 21-12.
TWI master operation.
The number of interrupts generated is kept to a minimum by automatic handling of most condi-
tions. Quick command and smart mode can be enabled to auto-trigger operations and reduce
software complexity.
21.5.1
Transmitting Address Packets
After issuing a START condition, the master starts performing a bus transaction when the mas-
ter address register is written with the 7-bit slave address and direction bit. If the bus is busy, the
TWI master will wait until the bus becomes idle before issuing the START condition.
Depending on arbitration and the R/W direction bit, one of four distinct cases (M1 to M4) arises
following the address packet. The different cases must be handled in software.
21.5.1.1
Case M1: Arbitration lost or bus error during address packet
If arbitration is lost during the sending of the address packet, the master write interrupt flag and
arbitration lost flag are both set. Serial data output to the SDA line is disabled, and the SCL line
is released. The master is no longer allowed to perform any operation on the bus until the bus
state has changed back to idle.
A bus error will behave in the same way as an arbitration lost condition, but the error flag is set in
addition to the write interrupt and arbitration lost flags.
IDLE
S
BUSY
BUSY
P
Sr
P
M3
M3
M2
M2
M1
M1
R
DATA
ADDRESS
W
A/A
DATA
Wait for
IDLE
APPLICATION
SW
SW
Sr
P
M3
M2
BUSY
M4
A
SW
A/A
A/A
A/A
M4
A
IDLE
IDLE
MASTER READ INT HOLD
MASTER WRITE INT HOLD
SW
SW
SW
BUSY
R/W
SW
Driver software
The master provides data
on the bus
Slave provides data on
the bus
A
A
R/W
BUSY
M4
Bus state
Mn
Diagram connections