Datasheet
209
ATtiny828 [DATASHEET]
8371A–AVR–08/12
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.
19.5.3 TWSSRA – TWI Slave Status Register A
z Bit 7 – TWDIF: TWI Data Interrupt Flag
This flag is set when a data byte has been successfully received, i.e. no bus errors or collisions have occurred during the
operation. When this flag is set the slave forces the SCL line low, stretching the TWI clock period. The SCL line is
released by clearing the interrupt flags.
Writing a one to this bit will clear the flag. This flag is also automatically cleared when writing a valid command to the
TWCMDn bits in TWSCRB.
z Bit 6 – TWASIF: TWI Address/Stop Interrupt Flag
This flag is set when the slave detects that a valid address has been received, or when a transmit collision has been
detected. When this flag is set the slave forces the SCL line low, stretching the TWI clock period. The SCL line is
released by clearing the interrupt flags.
If TWASIE in TWSCRA is set, a STOP condition on the bus will also set TWASIF. STOP condition will set the flag only if
system clock is faster than the minimum bus free time between STOP and START.
Writing a one to this bit will clear the flag. This flag is also automatically cleared when writing a valid command to the
TWCMDn bits in TWSCRB.
z Bit 5 – TWCH: TWI Clock Hold
This bit is set when the slave is holding the SCL line low.
This bit is read-only, and set when TWDIF or TWASIF is set. The bit can be cleared indirectly by clearing the interrupt
flags and releasing the SCL line.
z Bit 4 – TWRA: TWI Receive Acknowledge
This bit contains the most recently received acknowledge bit from the master.
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
TWCMD[1:0] TWDIR Operation
Bit 76543210
(0xBA) TWDIF TWASIF TWCH TWRA TWC TWBE TWDIR TWAS TWSSRA
Read/Write R/WR/W R R R/WR/WR/WR/W
Initial Value 0 0 0 0 0 0 0 0