2008-10-09 11:09 PM
SPI with DMA problems
2011-05-17 03:47 AM
I have managed to get the SPI working with DMA in basic form. However, I want to be able to do a 2 byte transfer with the DMA (full duplex) and then stop. I have approached this by turnig off the DMA Tx Request in the SPI DMA Channel Tx transfer complete interrupt, and similar in the DMA Rx.
The data to be transmitted then gets changed sometime later, and I then want to kick the DMA transfer off again. This I have done by tweaking the 2 byte data and re-enabling the SPI DMA Tx/Rx request. This approach almost works, but in circular mode, I seem to get 4 bytes (the 2 bytes of data twice) appearing on the SPI, as though the interrupt does not get in quick enough to turn the DMA request off. I thought a better approach maybe to use normal mode (ie not circular) but I cannot get the DMA to start again, even if I put the DMA Channel->CNDTR register back to 2 before re-enabling the DMA Tx Request. Any help would be appreciated. Thanks Darren.