2022-12-07 01:21 AM
Hello,
We are using UART polling and had it configured using STM32Cube. That was great until we realised there wasn’t any built-in checks for parity errors, overrun errors, …. How come those errors seems to be checked within the handler when using non-blocking functions (interrupt) but not within HAL_UART_Receive() or UART_WaitOnFlagUntilTimeout() ?
I understand that we could just use __HAL_UART_GET_FLAG(huart, UART_FLAG_PE) to check for parity errors but we would need to place it within HAL_UART_Receive() or UART_WaitOnFlagUntilTimeout() functions so would get overwritten everytime HAL is being regenerated. I couldn't find any USER CODE BEGIN/END macro within this file to add our own code and CUSTOM USER CODE BEGIN/END is not supported.
Is there any reason for those errors not to be checked when using polling ?
Would that ever be supported ?
How can we add those checks in a clean way ?
Thanks
2022-12-07 02:26 AM
It looks like you have graduated from the "HAL" nursery and ready to write your own UART code, suitable for your application.
What would you like to do in case of PE?
The overrun error is a more serious, it seems to block reception so it must be checked and removed, else it becomes a showstopper. Already reported several times ((
My quick work-around is disabling overrun detection on MCUs that support that.
2022-12-07 05:48 AM
Thanks for your response Pavel.
Oh really, is our best workaround to rewrite HAL_UART_Receive() then ? In case of PE, we would just like to return HAL_ERROR so whoever is calling HAL_UART_Receive() can act accordingly ( = rejecting the frame)