Product Specs

Table Of Contents
34 TWIS I
2
C compatible two-wire interface
slave with EasyDMA
Page
322
forces the slave to send more than TXD.MAXCNT bytes, the slave will send the byte specified in the ORC
register to the master instead. If this happens, an ERROR event will be generated.
The EasyDMA configuration registers, see TXD.PTR etc., are latched when the TXSTARTED 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 'TX prepared' flag and go back to the IDLE state
when it has stopped, see also Terminating an ongoing TWI transaction on page 324.
Each byte sent from the slave will be followed by an ACK/NACK bit sent from the master. The TWI master
will generate a NACK following the last byte that it wants to receive to tell the slave to release the bus so
that the TWI master can generate the stop condition. The TXD.AMOUNT register can be queried after a
transaction to see how many bytes were sent.
A typical TWI slave read command response is illustrated in Figure 89: The TWI slave responding to a read
command on page 322. Occurrence 2 in the figure illustrates clock stretching performed by the TWI slave
following a SUSPEND task.
Figure 89: The TWI slave responding to a read command
34.4 TWI slave responding to a write command
Before the TWI slave can respond to a write command the TWI slave must be configured correctly and
enabled via the ENABLE register. When enabled the TWI slave will be in its IDLE state where it will consume
I
IDLE
.
A write command is started when the TWI master generates a start condition on the TWI bus, followed by
clocking out the address and the READ/WRITE bit set to 0 (WRITE=0, READ=1). The READ/WRITE bit is
followed by an ACK/NACK bit (ACK=0 or NACK=1) response from the slave.
The TWI slave is able to listen for up to two addresses at the same time. Which addresses to listen for is
configured in the ADDRESS registers and the CONFIG register.
The TWI slave will only acknowledge (ACK) the write command if the address presented by the master
matches one of the addresses the slave is configured to listen for. The TWI slave will generate a WRITE
event if it acknowledges the write command.
The TWI slave is only able to detect a write command from the IDLE state.
The TWI slave will set an internal 'RX prepared' flag when the PREPARERX task is triggered.
When the write command is received the TWI slave will enter the RX state if the internal 'RX prepared' flag is
set.
If the internal 'RX prepared' flag is not set when the write command is received, the TWI slave will stretch the
master's clock until the PREPARERX task is triggered and the internal 'RX prepared' flag is set.
N
N-1
4
3
2
ADDR
Stretch
2
1
0
1
STOP
NACK
ACK
ACK
ACK
ACK
ACK
READ
START
CPU Lifeline
TWI
TXD.MAXCNT >= N+1
READ
TXSTARTED
TXD.PTR = 0x20000000
PREPARETX
SUSPEND
RESUME
STOPPED