
125
ATtiny40 [DATASHEET]
8263B–AVR–01/2013
The R/W specifies the direction of the transaction. If the R/W bit is low, it indicates a Master Write transaction, and
the master will transmit its data after the slave has acknowledged its address. Opposite, for a Master Read opera-
tion the slave will start to transmit data after acknowledging its address.
17.3.5
Data Packet
Data packets succeed an address packet or another data packet. All data packets are nine bits long, consisting of
one data byte and an acknowledge bit. The direction bit in the previous address packet determines the direction in
which the data is transferred.
17.3.6
Transaction
A transaction is the complete transfer from a START to a STOP condition, including any Repeated START condi-
tions in between. The TWI standard defines three fundamental transaction modes: Master Write, Master Read, and
combined transaction.
Figure 17-5 illustrates the Master Write transaction. The master initiates the transaction by issuing a START condi-
tion (S) followed by an address packet with direction bit set to zero (ADDRESS+W).
Figure 17-5. Master Write Transaction
Given that the slave acknowledges the address, the master can start transmitting data (DATA) and the slave will
ACK or NACK (A/A) each byte. If no data packets are to be transmitted, the master terminates the transaction by
issuing a STOP condition (P) directly after the address packet. There are no limitations to the number of data pack-
ets that can be transferred. If the slave signal a NACK to the data, the master must assume that the slave cannot
receive any more data and terminate the transaction.
Figure 17-6 illustrates the Master Read transaction. The master initiates the transaction by issuing a START condi-
tion followed by an address packet with direction bit set to one (ADRESS+R). The addressed slave must
acknowledge the address for the master to be allowed to continue the transaction.
Figure 17-6. Master Read Transaction
Given that the slave acknowledges the address, the master can start receiving data from the slave. There are no
limitations to the number of data packets that can be transferred. The slave transmits the data while the master sig-
nals ACK or NACK after each data byte. The master terminates the transfer with a NACK before issuing a STOP
condition.
Figure 17-7 illustrates a combined transaction. A combined transaction consists of several read and write transac-
tions separated by a Repeated START conditions (Sr).