Product Specs

Table Of Contents
34 TWIS I
2
C compatible two-wire interface
slave with EasyDMA
Page
323
4
3
The TWI slave will generate the RXSTARTED event and clear the internal 'RX prepared' flag ('unprepare
RX') when it enters the RX state. In this state the TWI slave will be able to receive the bytes sent by the TWI
master. The TWI slave will consume I
RX
in this mode.
The TWI slave will go back to the IDLE state if the TWI slave receives a restart command when it is in the
RX state.
The TWI slave is stopped when it receives the stop condition from the TWI master. A STOPPED event will
be generated when the transaction has stopped. The TWI slave will clear the internal 'RX prepared' flag
('unprepare RX') and go back to the IDLE state when it has stopped.
The receive buffer is located in RAM at the address specified in the TXD.PTR register. The TWI slave will
only be able to receive as many bytes as specified in the RXD.MAXCNT register. If the TWI master tries to
send more bytes to the slave than the slave is able to receive,these bytes will be discarded and the bytes will
be NACKed by the slave. If this happens, an ERROR event will be generated.
The EasyDMA configuration registers, see RXD.PTR etc., are latched when the RXSTARTED event is
generated.
The TWI slave can be forced to stop by triggering the STOP task. A STOPPED event will be generated when
the TWI slave has stopped. The TWI slave will clear the internal 'RX prepared' flag and go back to the IDLE
state when it has stopped, see also Terminating an ongoing TWI transaction on page 324.
The TWI slave will generate an ACK after every byte received from the master. The RXD.AMOUNT register
can be queried after a transaction to see how many bytes were received.
A typical TWI slave write command response is illustrated in Figure 90: The TWI slave responding to a write
command on page 323. Occurrence 2 in the figure illustrates clock stretching performed by the TWI slave
following a SUSPEND task.
Figure 90: The TWI slave responding to a write command
34.5 Master repeated start sequence
An example of a repeated start sequence is one in which the TWI master writes two bytes to the slave
followed by reading four bytes from the slave.
This is illustrated in Figure 91: A repeated start sequence, where the TWI master writes two bytes followed
by reading four bytes from the slave on page 324.
It is here assumed that the receiver does not know in advance what the master wants to read, and that
this information is provided in the first two bytes received in the write part of the repeated start sequence.
To guarantee that the CPU is able to process the received data before the TWI slave starts to reply to the
read command, the SUSPEND task is triggered via a shortcut from the READ event generated when the
read command is received. When the CPU has processed the incoming data and prepared the correct data
response, the CPU will resume the transaction by triggering the RESUME task.
M
M-1
2
ADDR
Stretch
2
1
0
STOP
ACK
1
ACK
ACK
ACK
ACK
ACK
WRITE
START
TWI
CPU Lifeline
RXD.MAXCNT >= M+1
RXD.PTR = 0x20000000
PREPARERX
WRITE
RXSTARTED
SUSPEND
STOPPED
RESUME