cancel
Showing results for 
Search instead for 
Did you mean: 

SPI and DMA

alexanderschoebel9
Associate
Posted on July 10, 2009 at 08:24

SPI and DMA

5 REPLIES 5
alexanderschoebel9
Associate
Posted on May 17, 2011 at 12:39

I am using SPI2 with DMA channel 4 to receive SPI data.

I have set up the DMA interrupt so that channel 4 IRS will be executed when all data was received.

My problem is that OVR bit of SPI2 is always set when entering the DMA channel 4 ISR. When I now set up DMA again it immediately reads a byte from SPI2 but in fact at this time there is nothing to read from SPI bus.

When I manually reset the OVR bit in the DMA ISR the DMA behaves like I would expect and reads only when there is traffic on SPI.

As far as I understand the DMA ISR is executed when all data has been read so how could there be an overrun?

It seems to me that the DMA transfer does not clear the RXNE bit which results in an OVR condition when receiving more bytes in a row.

Any suggestions?

Thanks!

kerry
Associate
Posted on May 17, 2011 at 12:39

I am having a very similar issue and was wondering if there have been any solutions.

I am observing that my Rx buffer always has a single byte appearing before the actual data. I thought the singe byte was related to the size of my Tx buffer but that is not the case. I have separated the Tx DMA task to send the data and then setup a new DMA Tx to send the dummy bytes in order to receive data. I still get an extra byte before valid data is returned.

Is clearing the OVR bit in the ISR the only solution to this problem or is there some other issue that I am missing?

Thanks for any comments or suggestions...

[ This message was edited by: kerry.lamb on 30-06-2009 18:48 ]

kerry
Associate
Posted on May 17, 2011 at 12:39

I have resolved this by fixing a problem in my DMA Rx routine.

dmatheis
Associate II
Posted on May 17, 2011 at 12:39

Hello,

what was the solution of your problem? I think I have smiliar issues with my SPI1 using DMA. After transfering some bytes via SPI1 out (MOSI) the SPI-DR is set to 0x00FF and the OVR bit is set. I'm using the DMA_GetFlagStatus(DMA1_FLAG_TC3) for waiting on the completion of the data transfer. After this step the Flag is reset and I want to read out received data, but due this problem I don't get any real data. Or should I use some ISRs for both DMA-Flags (Transmission complete of Rx and Tx)?

dmatheis
Associate II
Posted on May 17, 2011 at 12:39

Ok, it was my fault. I'll get the 0xFF because I'm working with an Eval-Board and not connected MISO-Pin (only Scope). I'm waiting for the arrival of the ic which gets connected to the SPI-interface and so the floating MISO-Pin got interpreted as high-level = 0xFF. Now when the MISO is connected to ground the SPI-DR has the value 0x00. But there is still confusion about the OVR-Flag. If I'm stepping through the code the OVR-Flag is shortly set when waiting on the arrival of the DMA1_FLAG_TC3-Flag but reset finally. Stepping over the whole send/receive function exits with setted OVR-Flag.

Any hints using spi with dma and this problem? 😉