136
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
detailed in Table 41. The data must be loaded when TWINT is High only. If not, the access will
be discarded, and the Write Collision bit, TWWC, will be set in the TWCR register. This
scheme is repeated until a STOP condition is transmitted by writing a logic 1 to the TWSTO bit
in the TWCR register.
After a repeated START condition (state $10) the 2-wire Serial Interface may switch to the
Master Receiver mode by loading TWDR with SLA+R.
Master Receiver Mode
In the Master Receiver mode, a number of data bytes are received from a Slave Transmitter,
see Figure 72. The transfer is initialized as in the Master Transmitter mode. When the START
condition has been transmitted, the TWINT flag is set by the hardware. The software must
then load TWDR with the 7-bit Slave address and the data direction bit (SLA+R). The 2-wire
Serial Interrupt flag must then be cleared by software before the 2-wire Serial Transfer can
continue.
When the Slave address and the direction bit have been transmitted and an acknowledgment
bit has been received, TWINT is set again and a number of status codes in TWSR are possi-
ble. Status codes $40, $48, or $38 apply to Master mode, and status codes $68, $78, or $B0
apply to Slave mode. The appropriate action to be taken for each of these status codes is
detailed in Table 42. Received data can be read from the TWDR register when the TWINT flag
is set High by the hardware. This scheme is repeated until a STOP condition is transmitted by
writing a logic 1 to the TWSTO bit in the TWCR register.
After a repeated START condition (state $10), the 2-wire Serial Interface may switch to the
Master Transmitter mode by loading TWDR with SLA+W.
Slave Receiver Mode
In the Slave Receiver mode, a number of data bytes are received from a Master Transmitter,
see Figure 73. To initiate the Slave Receiver mode, TWAR and TWCR must be initialized as
follows:
The upper 7 bits are the address to which the 2-wire Serial Interface will respond when
addressed by a Master. If the LSB is set, the 2-wire Serial Interface will respond to the general
call address ($00), otherwise it will ignore the general call address.
TWEN must be set to enable the 2-wire Serial Interface. The TWEA bit must be set to enable
the acknowledgment of the device’s own Slave address or the general call address. TWSTA
and TWSTO must be cleared.
When TWAR and TWCR have been initialized, the 2-wire Serial Interface waits until it is
addressed by its own Slave address (or the general call address if enabled) followed by the
data direction bit which must be “0” (write) for the 2-wire Serial Interface to operate in the
Slave Receiver mode. After its own Slave address and the write bit have been received, the 2-
wire Serial Interrupt flag is set and a valid status code can be read from TWSR. The status
code is used to determine the appropriate software action. The appropriate action to be taken
for each status code is detailed in Table 43. The Slave Receiver mode may also be entered if
arbitration is lost while the 2-wire Serial Interface is in the Master mode (see states $68 and
$78).
Table 39.
TWAR: Slave Receiver Mode Initialization
TWAR
TWA6
TWA5
TWA4
TWA3
TWA2
TWA1
TWA0
TWGCE
value
Device’s own Slave address
Table 40.
TWCR: Slave Receiver Mode Initialization
TWCR
TWINT
TWEA
TWSTA
TWSTO
TWWC
TWEN
-
TWIE
value
0
1
0
0
0
1
0
X