Usart idle interrupt question
Hello,
When I enable usart idle interrupt function on stm32g071rb, it fires the interrupt immediately even there is no communication on the bus.
I debug use cubeide and IAR. The results are the same.
When UE bit in USART_CR1set to 1, the IDLE bit in USART_ISR will change to 1 right now.
So after IDLE interrupt enabled, it will cause a interrupt.
I don't know why the IDLE bit in USART_ISR change to 1.
And I try to clear the IDLE bit in USART_ISR, by set IDLECF bit in USART_ICR before enable the interrupt. It no works.
But I add a delay_1_ms between uart_init and clear Idle interrupt flag, it works.
The code is below:
MX_USART1_UART_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
HAL_Delay(1); // work with this
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
__HAL_UART_CLEAR_IDLEFLAG(&huart2);
__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
__HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE);
