AnsweredAssumed Answered

DMA delay caused by Interrupts?

Question asked by Arno Thiele on Sep 4, 2017
Latest reply on Sep 12, 2017 by Arno Thiele
On my STM32F411RE I send data to my SPI2 peripheral port using DMA and it works fine, but the moment I enable any kind of interrupts for the NVIC it completely scrambles up my stream of DMA data on my SPI2 - MOSI pin. 
My basic configuration is rather simple. I use is an external DAC over SPI1 clocked by a TIM interrupt which is handled by the NVIC, plus an ADC on the SPI2 port trying to run it using DMA. Using an interrupt for the CS line on this ADC/SPI2/DMA port causes the same DMA data incoherency. It seems any interrupt that I enable does that. 
I am really puzzled, since DMA is supposed to boost efficiency and handling things in hardware undisturbed by any processing cycles. If I leave out DMA the whole code works fine. 
AN4031 makes some mention of DMA transfer delays and possible conditions that can cause it but it doesn’t seem to give much practical advice. My DMA init code is below and it works perfectly for sending 3 byte packages, as long as no interrupts are firing. 
If anyone could point me into the right direction I would be more than grateful!
     uint32_t var2Tx[4] ={0b00000000011111111111111111111111}; // has to be a 32bit array length 4 for some reason

        DMA_InitTypeDef dma_init;
        dma_init.DMA_BufferSize = 3;
     dma_init.DMA_PeripheralBaseAddr = (uint32_t)(&(SPI2->DR));
     dma_init.DMA_PeripheralDataSize = DMA_MemoryDataSize_Byte;
     dma_init.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
     dma_init.DMA_Mode = DMA_Mode_Circular;
     dma_init.DMA_MemoryInc = DMA_MemoryInc_Enable;
     dma_init.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
     dma_init.DMA_MemoryBurst = DMA_MemoryBurst_Single;
     dma_init.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
     dma_init.DMA_FIFOMode = DMA_FIFOMode_Disable; // direct mode
     dma_init.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;

     /* Configure Tx DMA */
     dma_init.DMA_Channel = DMA_Channel_0;
     dma_init.DMA_DIR = DMA_DIR_MemoryToPeripheral;
     dma_init.DMA_Memory0BaseAddr = (uint32_t) var2Tx;
     dma_init.DMA_Priority = DMA_Priority_High;
     DMA_Init(DMA1_Stream4, &dma_init);

     DMA_Cmd(DMA1_Stream4, ENABLE); /* Enable the DMA SPI TX Stream */

     /* Enable the SPI Tx DMA request */
     SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE);

Outcomes