681
SAM4CP [DATASHEET]
43051E–ATPL–08/14
34.7.3.5 Master Receiver Mode
The read sequence begins by setting the START bit. After the start condition has been sent, the master sends a 7-bit
slave address to notify the slave device. The bit following the slave address indicates the transfer direction, 1 in this case
(MREAD = 1 in TWI_MMR). During the acknowledge clock pulse (9th pulse), the master releases the data line (HIGH),
enabling the slave to pull it down in order to generate the acknowledge. The master polls the data line during this clock
pulse and sets the NACK bit in the TWI_SR if the slave does not acknowledge the byte.
If an acknowledge is received, the master is then ready to receive data from the slave. After data has been received, the
master sends an acknowledge condition to notify the slave that the data has been received except for the last data. See
Figure 34-9
. When the RXRDY bit is set in the TWI_SR, a character has been received in the receive-holding register
(TWI_RHR). The RXRDY bit is reset when reading the TWI_RHR.
RXRDY is used as Receive Ready for the PDC receive channel.
When a single data byte read is performed, with or without internal address (IADR), the START and STOP bits must be
set at the same time. See
Figure 34-9
. When a multiple data byte read is performed, with or without internal address
(IADR), the STOP bit must be set after the next-to-last data received. See
Figure 34-10
. For Internal Address usage see
Section 34.7.3.6
.
If the receive holding register (TWI_RHR) is full (RXRDY high) and the master is receiving data, the Serial Clock Line will
be tied low before receiving the last bit of the data and until the TWI_RHR is read. Once the TWI_RHR is read, the
master will stop stretching the Serial Clock Line and end the data reception. See
Figure 34-11
.
Warning:
When receiving multiple bytes in master read mode, if the next-to-last access is not read (the RXRDY flag
remains high), the last access will not be completed until TWI_RHR is read. The last access stops on the next-to-last bit.
When the TWI_RHR is read there is only half a bit period to send the stop bit command, else another read access might
occur (spurious access).
A possible workaround is to set the STOP bit before reading the TWI_RHR on the next-to-last access (within IT handler).
Figure 34-9.
Master Read with One Data Byte
Figure 34-10. Master Read with Multiple Data Bytes
A
S
DADR
R
DATA
NA
P
TXCOMP
Write START &
STOP Bit
RXRDY
Read RHR
TWD
NA
A
S
DADR
R
DATA n
A
A
DATA (n+1)
A
DATA (n+m)
DATA (n+m)-1
P
TWD
TXCOMP
Write START Bit
RXRDY
Write STOP Bit
after next-to-last data read
Read RHR
DATA n
Read RHR
DATA (n+1)
Read RHR
DATA (n+m)-1
Read RHR
DATA (n+m)