cancel
Showing results for 
Search instead for 
Did you mean: 

IDLE interrupt on STM32F0 fires when enabling it

B Zikhali
Associate III
Posted on January 31, 2018 at 15:53

Hi, 

I am trying to implement variable message length UART reception using USART IDLE IT and the DMA on the STM32F072 as detailed in this very helpful

https://community.st.com/0D50X00009XkW2nSAF

. I have discovered that the IDLE interrupt fires for absolutely no reason when I enable it: 

HAL_UART_Receive_DMA(&huart2, UART_RXBUFFER, UART_RXBUFFERSIZE);

SET_BIT(huart2.Instance->CR1, USART_CR1_IDLEIE);

This happens even if I disable and re-enable the UART before and after setting the IDLEIE flag. 

TLDR: Immediately after enabling the UART peripheral using the CR1_EN bit, the ISR_IDLE bit is set to 1. If I clear immediately after this, it will be raised again so I have to wait at least a few functions later to clear it, otherwise setting the CR1_IDLEIE enable will immediately trigger an interrupt.

 

 

This behavior is not present on the STM32 F4. 

#usart-idle #hal-usart #uart-dma #uart-it #stm32-f0 #f0
1 REPLY 1
Carlos Diaz
Associate II
Posted on May 06, 2018 at 09:15

Hi,

I think i have the same problem, i'm using a STM32F103RB device. Here's the capture of the LA i'm using:

0690X0000060B2gQAE.png

Right before enabling the IDLE interrupt i toggle the RXNE pin (this result on the falling edge), then i enable the IDLE interrupt which results on the IDLE signal to get high, and then i toggle the RXNE pin again (this results on the rising edge of the RXNE signal).

I solved it clearing the flag before enabling the interrupt, i stepped in the code and the IDLE flag on the Status Register is asserted when i enabled the IDLE interrupt so the interrupt handler was called before even setting the reception interrupt (in my case). This is the way i solved it:

__HAL_UART_CLEAR_IDLEFLAG(&HM_HANDLE);
__HAL_UART_ENABLE_IT(&HM_HANDLE, UART_IT_IDLE);�?�?

Regards