
131
ATtiny40 [DATASHEET]
8263B–AVR–01/2013
Bit 2 – TWAA: TWI Acknowledge Action
This bit defines the slave's acknowledge behavior after an address or data byte has been received from the mas-
ter. Depending on the TWSME bit in TWSCRA the Acknowledge Action is executed either when a valid command
has been written to TWCMDn bits, or when the data register has been read. Acknowledge action is also executed
if clearing TWAIF flag after address match or TWDIF flag during master transmit. See
Table 17-1 for details.
Bits 1:0 – TWCMD[1:0]: TWI Command
Writing these bits triggers the slave operation as defined by
Table 17-2. The type of operation depends on the TWI
slave interrupt flags, TWDIF and TWASIF. The Acknowledge Action is only executed when the slave receives data
bytes or address byte from the master.
Writing the TWCMD bits will automatically release the SCL line and clear the TWCH and slave interrupt flags.
TWAA and TWCMDn bits can be written at the same time. Acknowledge Action will then be executed before the
command is triggered.
The TWCMDn bits are strobed and always read zero.
17.5.3
TWSSRA – TWI Slave Status Register A
Table 17-1.
Acknowledge Action of TWI Slave
TWAA
Action
TWSME
When
0
Send ACK
0
When TWCMDn bits are written to 10 or 11
1
When TWSD is read
1
Send NACK
0
When TWCMDn bits are written to 10 or 11
1
When TWSD is read
Table 17-2.
TWI Slave Command
TWCMD[1:0]
TWDIR
Operation
00
X
No action
01
X
Reserved
10
Used to complete transaction
0
Execute Acknowledge Action, then wait for any START (S/Sr) condition
1
Wait for any START (S/Sr) condition
11
Used in response to an Address Byte (TWASIF is set)
0
Execute Acknowledge Action, then receive next byte
1
Execute Acknowledge Action, then set TWDIF
Used in response to a Data Byte (TWDIF is set)
0
Execute Acknowledge Action, then wait for next byte
1
No action
Bit
765
432
10
TWDIF
TWASIF
TWCH
TWRA
TWC
TWBE
TWDIR
TWAS
TWSCRA
Read/Write
R/W
R
R/W
Initial Value
000
00