2022-06-08 11:28 PM
I am using DMA for receiving data, but interrupts for transmitting over UART and I am experiencing following issue:
When the UART experiences Framing Error, the DMA stream triggers an interrupt to which HAL responds by eventually calling UART_DMAAbortOnError() which will zero both RX and TX transfer counters, but does not terminate the Interrupt driven transmission properly. If this happens during a transmission the UART interrupt handler calls UART_Transmit_IT() which contains following boundary check:
if (--huart->TxXferCount == 0U)
But the TxXferCount was set to 0 by the UART_DMAAbortOnError(), so the counter will wrap around and the UART will effectively dump half of the RAM.
Does anybody know the correct work-around, beside modifying HAL code?
Thanks
2022-06-09 05:43 AM
> Does anybody know the correct work-around, beside modifying HAL code?
I think not.
It is best to consider Cube/HAL code as a free gift for beginners, and useful for rapid prototyping.
But it is unfit for serious commercial purposes.
2022-06-09 05:53 AM
I eventually ended up disabling DMA using HAL_UART_DMAPause() and HAL_UART_DMAResume() while transmitting, since I did not need full-duplex communication. That seems to have helped.
2022-06-09 06:04 AM
It is certainly littered with stuff like this, but we keep hearing how it's MISRA, LINT'd or whatever.
And very little of it seems to have been real-world tested, stressed or gotten much QA scrutiny