Atmel Xplained Pro Evaluation Kit ATSAM4E-XPRO ATSAM4E-XPRO データシート

製品コード
ATSAM4E-XPRO
ページ / 1506
847
SAM4E [DATASHEET]
Atmel-11157D-ATARM-SAM4E16-SAM4E8-Datasheet_12-Jun-14
Reversal of Write to Read
The master initiates the communication by a write command and finishes it by a read command.
 describes the repeated start + reversal from Write to Read mode.
Figure 36-32. Repeated Start + Reversal from Write to Read Mode
Notes:
1. In this case, if TWI_THR has not been written at the end of the read command, the clock is automatically stretched before 
the ACK.
2. TXCOMP is only set at the end of the transmission because after the repeated start, SADR is detected again.
36.7.5.6 Using the Peripheral DMA Controller (PDC) in Slave Mode
The use of the PDC significantly reduces the CPU load.
Data Transmit with the PDC in Slave Mode
The following procedure shows an example to transmit data with PDC.
1.
Initialize the transmit PDC (memory pointers, transfer size).
2.
Start the transfer by setting the PDC TXTEN bit.
3.
Wait for the PDC ENDTX Flag either by using the polling method or ENDTX interrupt.
4.
Disable the PDC by setting the PDC TXTDIS bit.
5.
(Optional) Wait for the TXCOMP flag in TWI_SR before disabling the peripheral clock if required.
Data Receive with the PDC in Slave Mode
The following procedure shows an example to transmit data with PDC where the number of characters to receive
is known.
1.
Initialize the receive PDC (memory pointers, transfer size).
2.
Set the PDC RXTEN bit.
3.
Wait for the PDC ENDRX flag either by using polling method or ENDRX interrupt.
4.
Disable the PDC by setting the PDC RXTDIS bit.
5.
(Optional) Wait for the TXCOMP flag in TWI_SR before disabling the peripheral clock if required.
36.7.5.7 Read Write Flowcharts
The flowchart shown in 
 gives an example of read and write operations in Slave mode. A polling or
interrupt method can be used to check the status bits. The interrupt method requires that the Interrupt Enable
Register (TWI_IER) be configured first.
S
SADR
W
A
DATA0
A
DATA1
SADR
Sr
A
R
A
DATA2
A
DATA3
NA
P
Cleared after read
DATA0
DATA2
DATA3
DATA1
TXCOMP
TXRDY
RXRDY
As soon as a START is detected
Read TWI_RHR
SVACC
SVREAD
TWD
TWI_RHR
TWI_THR
EOSACC