STM32U575 UART issue when switching from MSI->HSE at same sysclock and peripheral clocks
Found a bit of an odd issue when switching from MSI (with a 160Mhz sysclock) to HSE (also with a 160Mhz sysclock).
We're using the HAL_UART and its giving a error callback with a zero value uart->ErrorCode.
The cause of it seems to be in the library HAL HAL_UART_IRQHandler()
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
{
#if !defined(USART_DMAREQUESTS_SW_WA)
/* Disable the UART DMA Rx request if enabled */
ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
#endif /* !USART_DMAREQUESTS_SW_WA */
/* Abort the UART DMA Rx channel */
if (huart->hdmarx != NULL)
{
/* Set the UART DMA Abort callback :
will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;
/* Abort DMA RX */
if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
{
/* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
huart->hdmarx->XferAbortCallback(huart->hdmarx);
}
}
else
{
/* Call user error callback */
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
/*Call registered error callback*/
last_call = 1;
huart->ErrorCallback(huart); //<- this is the error callback we see
(1) we are not using DMA so is correctly huart->hdmarx, but also we should not see USART_CR3_DMAR set
(2) when running on the MSI 160Mhz with the same peripheral clocks and baudates we do not the same issue, it only appear once we switch to HSE 160Mhz
That is - the identical code with only the sysclock source changed seems to behave in a different fashion.
We've sidestepped the issue by ignoring any errorcallback with a zero uart->ErrorCode, but that does not explain why it is happening.
Posting here in case anybody has any ideas, it is always nice to know why things happen.
