This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm using SysConfig to setup my project and, in order to communicate with another F28388D microcontroller, I'm testing SPI communication with DMA to have both TX and RX in the same core.
I can succesfully send data from SPIB to SPIA, but there's no way to get data alignment. I supposed to have data aligment only with hardware configuration, i.e. with correct TXFFIL/RXFFIL and DMA_BURST_SIZE and DMA_TRANSFER_SIZE, but it does not work: there is a way to assure it with hardware configuration or should I just implement it with a simple protocol?
Thanks and best regards,
Fabio
Hello Fabio,
I can succesfully send data from SPIB to SPIA, but there's no way to get data alignment. I supposed to have data aligment only with hardware configuration,
Can you clarify this question? I do not understand what you are looking for.
Hi Gus,
the fact is that I'm sending with DMA a data buffer uint16_t spiBTxDataBuff[MCU2_TO_1_DATASIZE] from SPIB to SPIA and I collect it into uint16_t spiARxDataBuff[MCU2_TO_1_DATASIZE] with DMA, with MCU2_TO_1_DATASIZE = 60.
For example, In SysConfig, I configured for SPIB:
TXFFIL = 12, DMA_BURST_SIZE=4 and DMA_TRANSFER_SIZE=15
and for SPIA:
RXFFIL = 12, DMA_BURST_SIZE=12 and DMA_TRANSFER_SIZE=5
I manually update spiBTxDataBuff every 5ms and I can see in spiARxDataBuff data refresh but every time with a shifting: in this example, with this configuration parameters, every sending I can see 24 words shifting each time.
I also tried to follow Technical Reference Manual indication, but with similar shifting issues.
My question is: is there a parameter configuration for both sending and receiving SPI with DMA, in order to receive data with no shifting or should I suppose to align data at receiving side in some way?
I hope it is clearer.
Thanks,
Fabio
Fabio,
My question is: is there a parameter configuration for both sending and receiving SPI with DMA, in order to receive data with no shifting or should I suppose to align data at receiving side in some way?
I don't think any data manipulation will be needed.
In order for me to understand the problem better, can you provide a screen shot of the transmit and receive buffers? What is the SPI character size you are using?
Thanks Gus,
here are the screenshots, but I apologize because I'm continuing developing and at the moment I changed buffer data from 60 to 48 words:
SPIB:
Running the code:
Considering xLastWakeTime (freeRTOS variabl), basically you can see the Tx buffer is not changing.
Instead, for SPIA:
During debugging:
In Rx buffer you can seee data shifting and with 48 words, now, sometimes data is aligned, but, of course, I would have it for any words number.
Just to be clearer:
uint16_t spiARxDataBuff[MCU2_TO_1_DATASIZE]; // Receive data buffer uint16_t spiBTxDataBuff[MCU2_TO_1_DATASIZE]; // Send data buffer // Addresses for SPI DMA channels const void *dma1TxAddr = (const void *)spiBTxDataBuff; const void *dma4RxAddr = (const void *)spiARxDataBuff;
I hope it is enough.
Thanks a lot,
Fabio
Fabio,
Emulator access while the application is running is affecting the operation of your code. When you have an expressions window constantly refreshing it will cause some interruption in the SPi transmission / DMA operation. This is called emulation suspend. I wonder if this is causing your data to be misaligned. Please change the emulation mode in the SPI and DMA configuration to allow these blocks to continue operation regardless of emulation suspend.