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

Which STM32?

Generally, in UART, transmitter and receiver are almost entirely independent units, so you can't "refresh" the Idle timer by transmitting.

One method may be to connect the Rx pin also to a timer pin externally, and handle the idle state in that timer.

JW

DCtech
Associate II

When I check the time in if case like if(__HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE) == SET){ print("time %d",timeCounter");}

I get very interesting result,

Sender send every 100 ms data to my device;

If I use the only receive DMA functions; time return 10, 110, 220,330 (Idle states working)

But If I received than after transmit data with uart this times values return 10,13,15,... a mean transmit function cahnge the line idle state, how is the possible ? IS the UART_FLAG_IDLE related only rx?

By the way I am using rs485 so when I start to transmitting, I set to tranceiver transmitter mode so Sender side receiver mode so my MCU does decide to IDLE this state ? is that possible?

TDK
Guru

You didn't answer JW's question.

The RM of the STM32F4 says IDLE is only set for reception events. Perhaps the data on the line is not what you think it is.

0693W00000BbORnQAN.png

If you feel a post has answered your question, please click "Accept as Solution".

Which STM32?

I don't understand your description. Post timing diagrams/waveforms.

JW

I am using Stm32F4 ​

DCtech
Associate II

I am using Stm32F4 is this flag ​check receive data line is idle or not.

DCtech
Associate II

And I am using Rs485 so, when I set the transmitting mode, is that affect the receive line ? ​

TDK
Guru

It could also be that you're not ready to receive by the time the transmitter sends the next byte. You mentioned using blocking receive function.

Transmitting doesn't affect the IDLE flag. Look somewhere else for the solution.

If you feel a post has answered your question, please click "Accept as Solution".