Specifications

123
3706C–MICRO–2/11
AT89LP3240/6440
18.6.4 Slave Transmitter Mode
In the Slave Transmitter mode, a number of data bytes are transmitted to a master receiver. To
initiate the Slave Transmitter mode, upper 7 bits of TWAR must be initialized with the address to
which the Two-wire Serial Interface will respond when addressed by a master. If the LSB is set,
the TWI will respond to the general call address (00h), otherwise it will ignore the general c
all
address. TWEN must be written to one to enable the TWI. The AA bit must be written to one to
enable the acknowledgment of the device’s own slave address or the general call address. STA
and STO must be written to zero.
When TWAR and TWCR have been initialized, the TWI waits until it is addressed by its own
slave address (or the general call address if enabled) followed by the da ta direction b
it. If the
direction bit is “1” (read), the TWI will operate in ST mode, otherwise SR mode is entered. After
its own slave address and the write bit have been received, the TWINT flag is set and a valid
status code can be read from TWSR. The status code is used to determine the appropriate soft-
ware action. The appropriate action to be taken for each status
code is detailed in Table 18-9.
The Slave Transmitter mode may also be entered if arbitration is lost while the TWI is in the
Master mode (see state B0h).
If the AA bit is written to zero during a transfer, the TWI will transmit the last byte of the transfer.
State C0h or state C8h will be entered, depending on whether the master receiver transmits a
NACK or ACK after the final b
yte. The TWI is switched to the not addressed Slave mode, and
will ignore the master if it continues the transfer. Thus the master receiver receives all “1sas
serial data. State C8h is entered if the master demands additional data bytes (by transmitting
ACK), even though the slave has transmitted the last byte (AA zero and expecting NACK from
the master). While AA is zero, the TWI doe
s not respond to its own slave address. However, the
Two-wire Serial Bus is still monitored and address recognition may resume at any time by set-
ting AA. This implies that the AA bit may be used to temporarily isolate the TWI from the Two-
wire Serial Bus.
Figure 18-14. Format and States in Slave Transmitter Mode
S SLA R A DATA A
A8h B8h
A
B0h
Reception of the own
slave address and one or
more data bytes
Last data byte transmitted.
Switched to not addressed
slave (TWEA = '0')
Arbitration lost as master
and addressed as slave
n
From master to slave
From slave to master
Any number of data bytes
and their associated acknowledge bits
This number (contained in TWSR) corresponds
to a defined state of the Two-wire Serial Bus. The
prescaler bits are zero or masked to zero
P or SDATA
C0h
DATA A
A
C8h
P or SAll 1's
A