Product Specs

Table Of Contents
33 TWIM I
2
C compatible two-wire interface
master with EasyDMA
Page
309
Note that the TWI master does not stop by itself when the RAM buffer is full, or when an error occurs. The
STOP task must be issued, through the use of a local or PPI shortcut, or in software as part of the error
handler.
The TWI master cannot get stopped while it is suspended, so the STOP task has to be issued after the TWI
master has been resumed.
Figure 81: The TWI master reading data from a slave
33.5 Master repeated start sequence
A typical 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 example uses shortcuts to perform the simplest type of repeated start
sequence, i.e. one write followed by one read. The same approach can be used to perform a repeated start
sequence where the sequence is read followed by write.
The figure Figure 82: A repeated start sequence, where the TWI master writes two bytes followed by reading
4 bytes from the slave on page 309 illustrates this:
Figure 82: A repeated start sequence, where the TWI master writes two bytes followed by reading 4
bytes from the slave
If a more complex repeated start sequence is needed and the TWI firmware drive is serviced in a low priority
interrupt it may be necessary to use the SUSPEND task and SUSPENDED event to guarantee that the
correct tasks are generated at the correct time. This is illustrated in Figure 83: A double repeated start
sequence using the SUSPEND task to secure safe operation in low priority interrupts on page 310.
M
M-1
1
2
3
4
Stretch
2
1
0
ADDR
3
2
1
0
2
ADDR
1
0
ADDR
1
STOP
NACK
ACK
STOP
NACK
ACK
ACK
ACK
ACK
ACK
READ
RESTART
ACK
ACK
ACK
ACK
READ
ACK
START
ACK
WRITE
START
CPU Lifeline
CPU Lifeline
CPU Lifeline
TWI
RXD.MAXCNT = M+1
TXD.MAXCNT = 2
RXD.MAXCNT = 4
STARTTX
STARTRX
STARTRX
SUSPEND
LASTTX
SUSPENDED
RESUME
LASTRX
STOP
LASTRX
STOP
STOPPED
STOPPED