cancel
Showing results for 
Search instead for 
Did you mean: 

Extra interrupts generated when using DMA and SPI?

kevinhuang
Associate II
Posted on January 07, 2014 at 02:03

I have a STM32 discovery board configured in slave mode receiving commands over SPI. When it receives a specific command byte, it activates DMA and sends back a set number of bytes back. I have a print statement at the beginning of my rx_isr function. I've noticed that when I receive the command byte, DMA is activated and begins to work (confirmed with the logic analyzer) but my rx_isr is called an additional 4 times. I would assume that since the DMA controller is now handling the SPI communication, I shouldn't receive any more calls to my isr. Does anyone have an idea what might be causing this? 

#dma #spi
3 REPLIES 3
Posted on January 08, 2014 at 10:06

Interrupts and DMA have different enable bits in SPI_CR2. Unless you disable the interrupts (by clearing RXNEIE bit), there will be an interrupt upon every received byte, whether handled by DMA or not.

JW

kevinhuang
Associate II
Posted on January 09, 2014 at 00:37

This makes sense, except I only receive 4 bytes back? In total I'm sending back 160 bytes back. It should either never trigger, or trigger for each and every one of those bytes, right?

chen
Associate II
Posted on January 09, 2014 at 10:34

Hi

'' except I only receive 4 bytes back? In total I'm sending back 160 bytes back.''

'' I have a print statement at the beginning of my rx_isr function.''

SPI and DMA are very fast in comparison with most display functions.

It may be that the display function is overwhelmed and looses the other displays, particularly if on buffer overflow it discards data.