AnsweredAssumed Answered

STOP reception in UART IO with interrupt

Question asked by thy on Jun 13, 2016
Latest reply on Jun 14, 2016 by thy
Hi everybody.

I have an stm32f4 micro trying to communicate with device via UART. I want to receive with interrupts and possibly, based on some conditions, stop the reception process (i.e. if some time expires from the last \n received). Since I am reading one char at once (receiving variable length strings) and the reception is called again within the callback (see https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fBest%20way%20to%20use%20HAL%20UART%20Receiver%20IT%20Function&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=18255), I have to stop it outside the callback. Unfortunately I am not able to do that, this causing an overrun error next time I start reception again (since the conditions allow to do that), and I am a little stuck. I tried with something like
__HAL_UART_DISABLE_IT(&UART_MOBILE_Handle, UART_IT_RXNE);
 
__HAL_UART_DISABLE_IT(&UART_MOBILE_Handle, UART_IT_PE);
 
__HAL_UART_DISABLE_IT(&UART_MOBILE_Handle, UART_IT_ERR);
but it seems not working.

Does anybody have any suggestion?

Thank you and regards.

Outcomes