2016-10-09 02:26 PM
What is the best way to restart a DMA servicing a UART using the HAL drivers?
On the first iteration the DMA works correctly; transfers new data and fires interrupt.On second iteration, the DMA transfers only one new data reading but doesn't fire an interrupt.On the third iteration and beyond, the DMA doen't interrupt or transfer data. It is inHAL_DMA_STATE_BUSY
.I've tried usingHAL_DMA_Abort,
HAL_UART_DMAStop
, and recalling the DMA initialisation routine but it still doesn't restart correctly.I can't find any documentation on how to restart the DMA with HAL drivers.Any help would be greatly appreciated. Thanks.2016-10-10 02:35 AM
Hello,
You can review the STM32 reference manual to see how the DMA worksThere is a set of DMA examples useful for your case in STM32cube packages
STM32CubeXX
that use HAL library. So, try to pick the one suitable for the device and board you are using and start from it. The example will give you an overview of how to design and code each part for your application.Regards
2016-10-10 04:49 AM
Hi kpnz,
It seems you don't need to restart DMA but you need to check how DMA is configured in your code and haw you call UART transmit function in your main function. Try to run the ''UART_HyperTerminal_DMA'' example in on of STM32CubeFx library package relevant to the STM32 device you are using.-Hannibal-2016-10-10 03:00 PM
Thank you for your replies.
I was using the example code from the STM32Cube project, but that code only uses the DMA once then enters an infinite loop.The problem was that the receiving UART stream continued after the DMA had completed, causing the UART to over-run, which seems to prevent the second DMA transfer from working. I added__HAL_USART_CLEAR_OREFLAG(&huart1);
before calling HAL_UART_Receive_DMA to ensure the over-run flag was clear and it's all working now.Will any of the other UART flags cause this same problem?2016-10-17 03:55 AM
Hi kpnz,
Which device you are using and which STM32Cube package version.Thanks -Hannibal-2024-02-13 05:16 AM
Thank u so much, i been fighting with the same issue for over a week, for me:
__HAL_UART_CLEAR_OREFLAG(&huart1);
did the trick!