There are 2 example projects with DelSig over SPIM, 16 bits, that may be
useful. On Creator start page "File", "Example Project" -
Hi danaaknight, Thanks for posting a reply.
I forgot to mention earlier on, that i was able to achieve this via writing to individual SPI tx register as in the case of the example suggested by you.
I want to support two SPI blocks transmitting large chunks of 16 bit data simultaneously. Thus i switched to DMA approach. But somehow it doesn't work out.
Correct me, if my understanding is wrong.
I went through the same problem: I was able to work with SPI 16 bits by using the C functions for writing in the TX buffer but was not able to work with DMA moving bytes to the 16 bits FIFO. It's interesting that DMA with SPI 8 bits works fine, but after making a few changes to do a 16 bit communication, the project doesn't work. One can make a 16 bit SPI communication with DMA using SPI 8 bit and transmitting the 2 bytes that form the word. I don't think this is an elegant solution, so I insisted on trying to discover what is wrong with the DMA + SPI 16 bits. After some time of work, I found a tiny modification that made my project with DMA + SPI 16 bit work.
When configuring the DMA transaction descriptor (in the CyDmaTdSetConfiguration() function), we have to increment the destination address (TD_INC_DST_ADR), which is the TX fifo (SPIM_TXDATA_PTR).
My project is attached and, for practical reasons, here follows the code of my DMA configuration (PS: the variable msg (source for the DMA) is a uint16 variable):
/* Defines for DMA_TX */
#define DMA_TX_BYTES_PER_BURST 2
#define DMA_TX_REQUEST_PER_BURST 1
#define DMA_TX_SRC_BASE (CYDEV_SRAM_BASE)
#define DMA_TX_DST_BASE (CYDEV_PERIPH_BASE)
/* Variable declarations for DMA_TX */
/* Move these variable declarations to the top of the function */
/* DMA Configuration for DMA_TX */
DMA_TX_Chan = DMA_TX_DmaInitialize(DMA_TX_BYTES_PER_BURST, DMA_TX_REQUEST_PER_BURST,
DMA_TX_TD = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_TX_TD, 2, DMA_TX_TD, DMA_TX__TD_TERMOUT_EN | TD_INC_DST_ADR);
CyDmaTdSetAddress(DMA_TX_TD, LO16((uint32)(&msg)), LO16((uint32)SPIM_TXDATA_PTR));
Paulo Aparecido Amaral Júnior
SPI_16bits_DMA.zip 2.3 MB