Datasheet

Table Of Contents
and wakes up the CPU, the TWI aborts operation and return to it’s idle state. If this cause any problems,
ensure that TWI Address Match is the only enabled interrupt when entering Power-down.
24.2.5. Control Unit
The Control unit monitors the TWI bus and generates responses corresponding to settings in the TWI
Control Register (TWCR). When an event requiring the attention of the application occurs on the TWI
bus, the TWI Interrupt Flag (TWINT) is asserted. In the next clock cycle, the TWI Status Register (TWSR)
is updated with a status code identifying the event. The TWSR only contains relevant status information
when the TWI Interrupt Flag is asserted. At all other times, the TWSR contains a special status code
indicating that no relevant status information is available. As long as the TWINT Flag is set, the SCL line
is held low. This allows the application software to complete its tasks before allowing the TWI
transmission to continue.
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.
24.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 pullup resistor for each of the TWI bus lines. All devices connected to the
bus have individual addresses, and mechanisms for resolving bus contention are inherent in the TWI
protocol.
Figure 24-2. TWI Bus Interconnection
SD A
SCL
........
R1 R2
V
CC
Device 1 Device 2
Device 3
Device n
24.3.1. TWI Terminology
The following definitions are frequently encountered in this section.
Atmel ATmega32A [DATASHEET]
Atmel-8155I-ATmega32A_Datasheet_Complete-08/2016
223