2023-10-08 03:51 AM
Hi,
HAL Version used - 1.10.0
I am using RTO interrupt to identify if the transmitter has finished sending a packet.
In the IRQ handler "void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)", this is considered as an error and it is aborting the ongoing DMA transfer from the UART peripheral to the memory. This is causing issues on our side.
The same is also posted here.
Why is this implemented it in this way ? Are we not supposed to use RTOF to identify if the transmitter has finished transmitting the packet ?
2023-10-08 05:56 AM
> Are we not supposed to use RTOF to identify if the transmitter has finished transmitting the packet ?
In the error callback you can check huart.ErrorCode & HAL_UART_ERROR_RTO to find the error reason.
> Why is this implemented it in this way ?
Short answer - because the RTO event signals end of packet, therefore end of transfer. You can then restart RX, possibly into a new buffer.
Even shorter answer... the UART "HAL" driver is not considered production quality - at least by some people on this forum. OK for a quick test of the hardware.
2023-10-08 07:04 AM
Thank you @Pavel A. for your prompt reply. My concern is that the handler "HAL_UART_IRQHandler" is aborting the ongoing DMA transfer (HAL_DMA_ABORT_IT()) and I am loosing the data. I have configured DMA for my UART. Is there any workaround for this ?
2023-10-08 08:25 AM
Make your own driver, or decrease the RTO timeout, or react faster to the RTO event to minimize the window from the timeout to the next RX byte.
2023-10-08 03:32 PM
You can use IDLE to detect the end of transmission instead.
2023-10-09 02:07 AM
Use HAL_UARTEx_ReceiveToIdle_DMA and HAL_UARTEx_RxEventCallback
2023-10-09 02:44 PM
Thank you @Karl Yamashita and @TDK for your suggestions.
I do receive variable amount of data on my UART. Let's say, I get an IDLE interrupt after I sent 100 kB of data from my PC. Does this IDLE interrupt mean that the data has already been copied to the DMA buffer ? In the IDLE interrupt handler, how can I verify that the entire data is copied into the DMA buffer. Please note that the RX data size is variable.
2023-10-09 03:17 PM
Data gets shifted to the DMA buffer continuously as it comes in, byte by byte. When the IDLE interrupt, or RX half- or full-complete interrupts happen, the data is already in there.
2023-10-09 03:49 PM
@Luke_abc Is that 100KB of data that is streamed at one time? Or is it multiples of packets that add up to 100KB of data? In the data, is there something that indicates the total data size? Is there a checksum? Each type of received data may require a different approach of saving data so knowing a little more about your data helps.
2023-10-10 12:34 AM - edited 2023-10-10 12:56 AM
Thank you @Karl Yamashita for you reply. Data is streamed all at one time.
That data size will not be more than 64 KB.
Can I use the idle interrupt to confirm all the data (let's say 64 KB) is copied to the dma buffer ?