AnsweredAssumed Answered

STM32F04xx USART Idle line detection

Question asked by Tom Eaton on Mar 9, 2018
Latest reply on Mar 9, 2018 by T J

I have been trying to use the USART idle line detection flag to  detect when an incoming transmission stream has ended. 

if((USART1->ISR & USART_ISR_RXNE) != RESET) {   if ((1+RX_BUFFER_POS) < RX_BUFFER_SIZE) {         RX_Buffer[1 + RX_BUFFER_POS++] = USART1->RDR;   } }     if(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_IDLE)) {     can_read = 1;     __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_IDLE); }

I used this code to set a flag, can_read which is checked in the main loop. If the flag is true, then I parse the data.


The problem is that the IDLE flag is being set after each character received, not after the end of the string.


Please can I have some clarification on when the IDLE interrupt is triggered.


Many thanks.