Product Specs

Table Of Contents
31 SPIM Serial peripheral interface master with
EasyDMA
Page
282
#define BUFFER_SIZE 4
typedef struct ArrayList
{
uint8_t buffer[BUFFER_SIZE];
} ArrayList_type;
ArrayList_type MyArrayList[3];
Disabling a peripheral that has the same ID as the SPI will not reset any of the registers that are shared with
the SPI. It is therefore important to configure all relevant SPI registers explicitly to secure that it operates
correctly.
See the Instantiation table in Instantiation on page 24 for details on peripherals and their IDs.
31.2 EasyDMA
The SPI master implements EasyDMA for reading and writing of data packets from and to the DATA RAM
without CPU involvement.
The RXD.PTR and TXD.PTR point to the RXD buffer (receive buffer) and TXD buffer (transmit buffer)
respectively, see Figure 69: SPIM SPI master with EasyDMA on page 281. RXD.MAXCNT and
TXD.MAXCNT specify the maximum number of bytes allocated to the buffers.
The SPI master will automatically stop transmitting after TXD.MAXCNT bytes have been transmitted and
RXD.MAXCNT bytes have been received. If TXD.MAXCNT is larger than RXD.MAXCNT, the superfluous
received bytes will be ignored. If RXD.MAXCNT is larger than TXD.MAXCNT, the remaining transmitted
bytes will contain the value defined in the ORC register.
If the RXD.PTR and the TXD.PTR are not pointing to the Data RAM region, an EasyDMA transfer may result
in a HardFault or RAM corruption. See Memory on page 23 for more information about the different memory
regions.
The .PTR and .MAXCNT registers are double-buffered. They can be updated and prepared for the next
transmission immediately after having received the STARTED event.
The ENDRX/ENDTX event indicate that EasyDMA has finished accessing respectively the RX/TX buffer in
RAM. The END event gets generated when both RX and TX are finished accessing the buffers in RAM.
31.2.1 EasyDMA list
EasyDMA supports one list type.
The supported list type is:
Array list
EasyDMA array list
The EasyDMA array list can be represented by the data structure ArrayList_type.
For illustration, see the code example below. This data structure includes only a buffer with size equal
to Channel.MAXCNT. EasyDMA will use the Channel.MAXCNT register to determine when the buffer
is full. Replace 'Channel' by the specific data channel you want to use, for instance 'NRF_SPIM->RXD',
'NRF_SPIM->TXD', 'NRF_TWIM->RXD', etc.
The Channel.MAXCNT register cannot be specified larger than the actual size of the buffer. If
Channel.MAXCNT is specified larger than the size of the buffer, the EasyDMA channel may overflow the
buffer.
This array list does not provide a mechanism to explicitly specify where the next item in the list is located.
Instead, it assumes that the list is organized as a linear array where items are located one after the other in
RAM.