2021-06-18 06:40 AM
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?
2021-06-18 06:48 AM
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
2021-06-18 07:25 AM
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?
2021-06-18 07:50 AM
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?
2021-06-18 07:58 AM
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.
2021-06-18 08:10 AM
Which STM32?
I don't understand your description. Post timing diagrams/waveforms.
JW
2021-06-18 08:15 AM
I am using Stm32F4
2021-06-18 08:16 AM
I am using Stm32F4 is this flag check receive data line is idle or not.
2021-06-18 08:19 AM
And I am using Rs485 so, when I set the transmitting mode, is that affect the receive line ?
2021-06-18 09:36 AM
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.