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).
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 indma_rx_buf[pos]
is larger than buffer size. Further cheking shows that it happens in timout case (flag is 1) and thatdma_uart_rx.prevCNDTR
is smaller thancurrCNDTR
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,