STMicroelectronics / STM32CubeH7

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
https://www.st.com/en/embedded-software/stm32cubeh7.html
Other
479 stars 298 forks source link

UART: HAL_UART_ErrorCallback is not called reliably #263

Closed Meravid closed 3 months ago

Meravid commented 1 year ago

Caution The Issues are strictly limited for the reporting of problem encountered with the software provided in this project. For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the ST Community/STM32 MCUs forum

Describe the set-up

Describe the bug

The HAL_UART_ErrorCallback is not called reliably, if a frame or noise error occurs.

Background: The device is receiving several messages via UART with a wrong baudrate. Hence, HAL_UART_ErrorCallback is called, which is used to recover from the error and keep the UART reception alive for new messages. But HAL_UART_ErrorCallback is not always called, sometimes after the second or third or ... message HAL_UART_ErrorCallback is not called although the UART handle indicates a error by its member ErrorCode.

How To Reproduce

grafik grafik grafik

Additional context

The workaround which worked is to poll cyclic the ErrorCode of the UART and reset the UART reception in a case of error.

Things which didn't help.

Reinitialize in interrupt context

extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart)
{
    if(huart->Instance == mcu.uart_debug().GetInstance())
    {
        HAL_UARTEx_ReceiveToIdle_DMA(&huart4, (uint8_t*)rxBuffer, size);

        // Disable half complete interrupt
        __HAL_DMA_DISABLE_IT(_handle.hdmarx, DMA_IT_HT);
    }
}
extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart)
{
    if(huart->Instance == mcu.uart_debug().GetInstance())
    {
        HAL_UART_DeInit(&huart);
        HAL_UART_Init(&huart);
        HAL_UARTEx_ReceiveToIdle_DMA(&huart4, (uint8_t*)rxBuffer, size);

        // Disable half complete interrupt
        __HAL_DMA_DISABLE_IT(_handle.hdmarx, DMA_IT_HT);
    }
}

Set an event in interrupt and reinitialize in normal thread context

Screenshots If applicable, add screenshots to help explain your problem.

RJMSTM commented 1 year ago

Hello @Meravid,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

KRASTM commented 4 months ago

Hello @Meravid,

As a result of the STM32CubeH7 being recently updated to v1.11.2, can you please verify that the issue still remains.

With regards.

KRASTM commented 3 months ago

Hello @Meravid,

Please allow me to close the issue, since there is no activity in a while.

With regards.