akospasztor / stm32-dma-uart

Efficient DMA timeout mechanism for peripheral DMA configured in circular mode demonstrated on a STM32 microcontroller.
MIT License
125 stars 46 forks source link

Hard fault when DMA transmitting at the same time #7

Open ranshalit opened 4 years ago

ranshalit commented 4 years ago

Hello,

The demonstration works perfectly. But on trying to add continuous dma transmit HAL_UART_Transmit_DMA at the same time, we get hard fault. I first verified that dma transmit alone works without any issues, and it does. Than I tried to understand why I get hard fault: According to my testing I see that pos index in dma_rx_buf[pos] is larger than buffer size. Further cheking shows that it happens in timout case (flag is 1) and that dma_uart_rx.prevCNDTR is smaller than currCNDTR which gives a negative value for length , i.e. very large value !

length = (dma_uart_rx.prevCNDTR < DMA_BUF_SIZE) ? (dma_uart_rx.prevCNDTR - currCNDTR) I first thought that maybe the system is too busy, but trying to do something else (instead of dma transmission does not give the same fault).

I still try to understand why it happens.

Thanks for any suggestion,