cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with DMA problems

darren
Associate
Posted on October 10, 2008 at 08:09

SPI with DMA problems

1 REPLY 1
darren
Associate
Posted on May 17, 2011 at 12:47

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.