cancel
Showing results for 
Search instead for 
Did you mean: 

USART IDLE Line Interrupt

DCtech
Associate II

I have an idle interrupt, on usart2 handle;

void USART2_IRQHandler(void)
 
{
 
 /* USER CODE BEGIN USART2_IRQn 0 */
 
  /* UART IDLE Interrupt */
 
    if(__HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE) == SET)  
 
    {
 
	 __HAL_UART_CLEAR_IDLEFLAG(&huart2);
 
receivedDataFlag = 1;
 
}
 
}

When I use the this function check line idle states and decide the data received or not received. But this interrup trigger while transmitting. How can I seperate receive data line idle and receive idle ?

I want to trigger just receive data line idle, how can I do that ? What other register should I look at?

11 REPLIES 11

> I am using rs485

Is there an echo from Tx to Rx?

JW

DCtech
Associate II

I found another problem cause that, but I dont understand, why ?

When I received the data, I set to Rs485 to tranceiver mode and start the data transfer with HAL_UART_Transmit_DMA(&huart2, (uint8_t *)rs485Tx, TX_BUF_LENGHT);

when the tx completed my code like this:

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)

{

 HAL_UART_DMAStop(&huart2);

 dmaTransmitCompletedFlag = 1;

 RS485_Set_Receive_Mode();

 HAL_UART_Receive_DMA(&huart2,(uint8_t*)dma_rx_buf,DMA_BUF_SIZE); // *** This line cause the trig IDLE interrupt

 waitForTransmittingData = 0;

}

Every HAL_UART_Receive_DMA calling in TxCompleted Interrupt, IDLE interrupt trigger.

But sender send to data every 100 ms, but I see the IDLE interrupt trigger every 5 ms. Why this happening If I remove the HAL_UART_Receive_DMA line, I see every 100 ms trigger.