Page 1 of 1

[HAL][STM32] DMA isr ignores enabled interrupts

Posted: Thu Jan 05, 2017 1:53 pm
by thor.thau
ChibiOS: 16.1.6
SVN: branches/stable_16.1.x@10005
MCU: STM32F030x8
Module: DMAv1/stm32_dma

I am using the UART driver setup with USART1, TX requests on DMA1 channel 4 and RX requests on DMA1 channel 5. When I am using uartStartSend then only half of the bytes are send.

The problem is that with the STM32F030x8 MCU DMA1 channel 4 and channel 5 isr is shared OSAL_IRQ_HANDLER(STM32_DMA1_CH4567_HANDLER).

1. Channel 4 HTIF flag (half transfer) set in DMA_ISR register but the shared isr is not executed
2. Channel 5 triggers the shared isr
3. dmaServeInterrupt is executed for channel 4 and triggers on the HTIF because enabled interrupts are not checked

Code: Select all

diff --git a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
index ad0f62836..99f1814e8 100644
--- a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
+++ b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
@@ -48,7 +48,7 @@
 /**
  * @brief   Mask of the ISR bits passed to the DMA callback functions.
  */
-#define STM32_DMA_ISR_MASK          0x0F
+#define STM32_DMA_ISR_MASK          0x0E
 
 /**
  * @brief   From stream number to shift factor in @p ISR and @p IFCR registers.
@@ -444,7 +444,7 @@ typedef struct {
   uint32_t idx = (dmastp)->selfindex;                                       \
                                                                             \
   flags = ((dmastp)->dma->ISR >> (dmastp)->shift) & STM32_DMA_ISR_MASK;     \
-  if (flags & STM32_DMA_ISR_MASK) {                                         \
+  if (flags & (dmastp)->channel->CCR) {                                     \
     (dmastp)->dma->IFCR = flags << (dmastp)->shift;                         \
     if (_stm32_dma_isr_redir[idx].dma_func) {                               \
       _stm32_dma_isr_redir[idx].dma_func(_stm32_dma_isr_redir[idx].dma_param, flags); \


I have chosen to reduce the STM32_DMA_ISR_MASK because I determine that GIF flag is unnecessary when the code already uses TEIF, HTIF and TCIF flags in DMA_ISR.

Re: [HAL][STM32] DMA isr ignores enabled interrupts

Posted: Wed Jan 11, 2017 11:29 am
by Giovanni
Hi,

Thanks, fixed as bug #812.

Giovanni