655
SAM4CP [DATASHEET]
43051E–ATPL–08/14
[xxxxxxx(7-bit) + LASTXFER(1-bit)
(1)
+ xxxx(4-bit) + PCS (4-bit) + DATA (8 to 16-bit)] with PCS equals the chip
select to assert, as defined in
Section 33.8.4 ”SPI Transmit Data Register”
and LASTXFER bit at 0 or 1 depending
on the CSAAT bit.
Note:1.
Optional.
CSAAT, LASTXFER and CSNAAT bits are discussed in
Section 33.7.3.9 ”P(pán)eripheral Deselection with PDC”
.
If LASTXFER is used, the command must be issued before writing the last character. Instead of LASTXFER, the
user can use the SPIDIS command. After the end of the PDC transfer, it is necessary to wait for the TXEMPTY flag
and then write SPIDIS into the SPI Control Register (SPI_CR). This does not change the configuration register
values. The NPCS is disabled after the last character transfer. Then, another PDC transfer can be started if the
SPIEN has previously been written in the SPI_CR.
33.7.3.6 SPI Peripheral DMA Controller (PDC)
In both Fixed and Variable peripheral select modes, the Peripheral DMA Controller (PDC) can be used to reduce
processor overhead.
The Fixed Peripheral Selection allows buffer transfers with a single peripheral. Using the PDC is an optimal means, as
the size of the data transfer between the memory and the SPI is either 8 bits or 16 bits. However, if the peripheral
selection is modified, the SPI_MR must be reprogrammed.
The Variable Peripheral Selection allows buffer transfers with multiple peripherals without reprogramming the SPI_MR.
Data written in the SPI_TDR is 32 bits wide and defines the real data to be transmitted and the destination peripheral.
Using the PDC in this mode requires 32-bit wide buffers, with the data in the LSBs and the PCS and LASTXFER fields in
the MSBs. However, the SPI still controls the number of bits (8 to16) to be transferred through MISO and MOSI lines with
the chip select configuration registers (SPI_CSRx). This is not the optimal means in terms of memory size for the buffers,
but it provides a very effective means to exchange data with several peripherals without any intervention of the
processor.
Transfer Size
Depending on the data size to transmit, from 8 to 16 bits, the PDC manages automatically the type of pointer's size it has
to point to. The PDC performs the following transfer, depending on the mode and number of bits per data.
Fixed Mode:
8-bit Data:
Byte transfer, PDC Pointer Address = Address + 1 byte,
PDC Counter = Counter - 1
8-bit to 16-bit Data:
2 bytes transfer. n-bit data transfer with don’t care data (MSB) filled with 0’s,
PDC Pointer Address = Address + 2 bytes,
PDC Counter = Counter - 1
Variable Mode:
In variable Mode, PDC Pointer Address = Address + 4 bytes and PDC Counter = Counter - 1 for 8 to 16-bit transfer
size.
When using the PDC, the TDRE and RDRF flags are handled by the PDC. The user’s application does not have to
check these bits. Only End of RX Buffer (ENDRX), End of TX Buffer (ENDTX), Buffer Full (RXBUFF), TX Buffer
Empty (TXBUFE) are significant. For further details about the Peripheral DMA Controller and user interface, refer
to the PDC section of the product datasheet.
33.7.3.7 Peripheral Chip Select Decoding
The user can program the SPI to operate with up to 15 slave peripherals by decoding the four Chip Select lines, NPCS0
to NPCS3 with an external decoder/demultiplexer. This can be enabled by writing a 1 to the PCSDEC bit in the SPI_MR.