So you are now able to start a SPI transference through writing a data in the SPIx_PUSHR register? If yes the only missing thing is the DMA configuration.
Please try with the following function with the DMASourceAddress as your buffer address, DMADestinationAddress as the two low bits in the SPIx_PUSHR, SourceIncrement as 2 bytes, DestinationIncrement as 0 bytes, SourceOffset as the size in bytes of your buffer, DestinationOffset as 0, SizeElements as 1 for 2 bytes, Iterations as the amount of samples in your buffer, BytesPerTransaction two bytes and disableRequest as 0 for keep always the transactions enabled:
/*
* DMAMUX_Channel Select the DMA channel that you want to configure.
* SourceTrigger The trigger to start a transference.
* DMASourceAddress The source address.
* DMADestinationAddress The destination address.
* SourceIncrement The increment in bytes in the source address every time a transaction is done.
* DestinationIncrement The increment in bytes in the destination address every time a transaction is done.
* SourceOffset The amount of bytes to add or subtract to the source address after a completion of a major loop (could be negative).
* DestinationOffset The amount of bytes to add or subtract to the destination address after a completion of a major loop (could be negative).
* SizeElements The size of the data to transfer (0 -> 1 byte, 1 -> 2 bytes, 2 -> 4 bytes, 4 -> 16 bytes, 5 -> 32 bytes).
* Iterations How many minor loops are in a major loop?
* BytesPerTransaction How many bytes are transferred in a minor loop?
* disableRequest Do you want to disable the channel requests after a major loop?
*/
void DMA_InitChannel(uint8_t DMAMUX_Channel, uint8_t SourceTrigger, uint32_t DMASourceAddress, uint32_t DMADestinationAddress, \
uint8_t SourceIncrement, uint8_t DestinationIncrement, int32_t SourceOffset, int32_t DestinationOffset, \
uint8_t SizeElements, uint16_t Iterations, uint16_t BytesPerTransaction, uint8_t disableRequest)
{
SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK;
SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;
DMAMUX_CHCFG(DMAMUX_Channel) |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(SourceTrigger); //Enable the channel and select the source trigger.
DMA_SERQ |= DMA_SERQ_SERQ(DMAMUX_Channel); //Enable the request register for this channel.
DMA_SADDR(DMAMUX_Channel) = DMASourceAddress; //Select the source address.
DMA_DADDR(DMAMUX_Channel) = DMADestinationAddress; //Select the destination address.
DMA_SOFF(DMAMUX_Channel) = SourceIncrement; //Source offset (i.e. SOFF = 2 points to elements 0, 2, 4, etc.).
DMA_ATTR(DMAMUX_Channel) = DMA_ATTR_SSIZE(SizeElements) | DMA_ATTR_DSIZE(SizeElements); //Select elemnt's size.
DMA_NBYTES_MLNO(DMAMUX_Channel) = BytesPerTransaction; //Bytes per transaction.
DMA_SLAST(DMAMUX_Channel) = SourceOffset; //Source offset after a major iteration count.
DMA_DOFF(DMAMUX_Channel) = DestinationIncrement; //Destination offset (i.e. DOFF = 2 points to elements 0, 2, 4, etc.).
DMA_CITER_ELINKNO(DMAMUX_Channel) = DMA_CITER_ELINKNO_CITER(Iterations); //Iterations (minor loops).
DMA_DLAST_SGA(DMAMUX_Channel) = DestinationOffset; //Destination offset after a major iteration count.
DMA_BITER_ELINKNO(DMAMUX_Channel) = DMA_BITER_ELINKNO_BITER(Iterations); //Iterations (minor loops).
DMA_CSR(DMAMUX_Channel) = (disableRequest & 0x01) << DMA_CSR_DREQ_SHIFT;
}
You need to configure the eDMA with the operation mode of periodic trigger (where the PIT 0 triggers the eDMA channel 0, the PIT 1 triggers the eDMA channel 1, etc.) through the register DMAMUX_CHCFGn[TRIG] (please see the description of this register).
Earl Orlando.