2020-07-23 05:07 AM
I am using STM32F407VG. I am transmitting data from PC to STM32 using uart. I wrote the code to receive 100 bytes. Firstly I call the HAL_UART_Receive_DMA more than once and then I sent the data from PC to STM32.I observed it receives only 100 bytes,means only one time DMA is receiving the data. except in first call, In remaining calls it is HAL_UART_STATE_BUSY_RX state. So what happen when already Rx process is ongoing(HAL_UART_STATE_BUSY_RX)?
2020-07-23 08:31 AM
It returns HAL_BUSY without doing anything else.
HAL code is included in your project. It's easily inspected.
2020-07-23 12:16 PM
Theoretically it will return "busy" error, but in real life sooner or later it will fail in some way because __HAL_LOCK() is not thread-safe. That is what you get when the code is made by brainless code-monkeys...
2020-07-23 12:20 PM
2020-07-23 12:49 PM
Indeed, but it will be pretty ugly code to implement it in a way that HAL_UART_Receive_DMA() is called only from one of those contexts.
Anyway this approach is architecturally dumb and sub-optimal as a whole. Normally receive is implemented in such a way that it is started only once and then, when the callback informs that there is some new data received, main code gets the new data from the driver.
2020-07-24 01:07 AM
So there is no use of those remaining Receive calls in HAL_BUSY state.