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 12:33 PM
> I am using rs485
Is there an echo from Tx to Rx?
JW
2021-06-20 11:08 PM
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.