Datasheet
154
ATmega8A [DATASHEET]
8159E–AVR–02/2013
The TWINT Flag is set in the following situations:
• After the TWI has transmitted a START/REPEATED START condition.
• After the TWI has transmitted SLA+R/W.
• After the TWI has transmitted an address byte.
• After the TWI has lost arbitration.
• After the TWI has been addressed by own slave address or general call.
• After the TWI has received a data byte.
• After a STOP or REPEATED START has been received while still addressed as a Slave.
When a bus error has occurred due to an illegal START or STOP condition.
21.3 Two-wire Serial Interface Bus Definition
The Two-wire Serial Interface (TWI) is ideally suited for typical microcontroller applications. The TWI protocol
allows the systems designer to interconnect up to 128 different devices using only two bi-directional bus lines, one
for clock (SCL) and one for data (SDA). The only external hardware needed to implement the bus is a single pull-
up resistor for each of the TWI bus lines. All devices connected to the bus have individual addresses, and mecha-
nisms for resolving bus contention are inherent in the TWI protocol.
Figure 21-2. TWI Bus Interconnection
21.3.1 TWI Terminology
The following definitions are frequently encountered in this section.
21.3.2 Electrical Interconnection
As depicted in Figure 21-2, both bus lines are connected to the positive supply voltage through pull-up resistors.
The bus drivers of all TWI-compliant devices are open-drain or open-collector. This implements a wired-AND func-
tion which is essential to the operation of the interface. A low level on a TWI bus line is generated when one or
more TWI devices output a zero. A high level is output when all TWI devices tri-state their outputs, allowing the
Device 1
Device 2
Device 3
Device n
SDA
SCL
........
R1 R2
V
CC
Table 21-1. TWI Terminology
Term Description
Master The device that initiates and terminates a transmission. The Master also generates the
SCL clock.
Slave The device addressed by a Master.
Transmitter The device placing data on the bus.
Receiver The device reading data from the bus.