694
SAM4CP [DATASHEET]
43051E–ATPL–08/14
34.7.5 Slave Mode
34.7.5.1 Definition
Slave Mode is defined as a mode where the device receives the clock and the address from another device called the
master.
In this mode, the device never initiates and never completes the transmission (START, REPEATED START and STOP
conditions are always provided by the master).
34.7.5.2 Application Block Diagram
Figure 34-25. Slave Mode Typical Application Block Diagram
34.7.5.3 Programming Slave Mode
The following fields must be programmed before entering Slave mode:
1.
TWI_SMR.SADR: The slave device address is used in order to be accessed by master devices in read or write
mode.
2.
TWI_CR.MSDIS: Disables the master mode.
3.
TWI_CR.SVEN: Enables the slave mode.
As the device receives the clock, values written in TWI_CWGR are ignored.
34.7.5.4 Receiving Data
After a START or REPEATED START condition is detected and if the address sent by the Master matches with the Slave
address programmed in the SADR (Slave Address) field, SVACC
(Slave Access) flag is set and SVREAD (Slave Read)
indicates the direction of the transfer.
SVACC remains high until a STOP condition or a repeated START is detected. When such a condition is detected, the
EOSACC (End Of Slave Access) flag is set.
Read Sequence
In the case of a Read sequence (SVREAD is high), TWI transfers data written in the TWI_THR (TWI Transmit Holding
Register) until a STOP condition or a REPEATED START + an address different from SADR is detected. Note that at the
end of the read sequence TXCOMP (Transmission Complete) flag is set and SVACC reset.
As soon as data is written in the TWI_THR, the TXRDY (Transmit Holding Register Ready)
flag is reset, and it is set
when the internal shifter is empty and the sent data acknowledged or not. If the data is not acknowledged, the NACK flag
is set.
Note that a STOP or a REPEATED START always follows a NACK.
See
Figure 34-26 on page 695
.
Write Sequence
In the case of a Write sequence (SVREAD is low), the RXRDY (Receive Holding Register Ready) flag is set as soon as a
character has been received in the TWI_RHR (TWI Receive Holding Register). RXRDY is reset when reading the
TWI_RHR.
R
R
VDD
TWD
Host with
TWI
Interface
TWCK
LCD
Controller
Slave 1
Slave 2
Slave 3
Host with TWI
Interface
Host with TWI
Interface
Master