2017-01-16 02:02 PM
If i start an UART receive with an interrupt looking for the next inbound byte/char;
HAL_UART_Receive_IT(&huart1, &UART1_Data, 1);
how can i cancel the receive before receiving the next byte/char?
2017-01-16 02:08 PM
I'd imagine you could flag it yourself and handle in the callback.
2017-01-16 03:13 PM
when you say flag it, do you mean force an interrupt by setting a interrupt bit in the uart and then handling the interrupt?
2017-01-16 03:29 PM
did you fix it ?
would you like to use the DAM rx functions ?
I get an interrupt on each and every character.
2017-01-16 06:57 PM
I mean on your side, presumably you're going to want it to receive again at some point, and if you don't keep servicing it you'll have it overrun.
Flag that you want to cancel, eat the byte if you don't want it, and don't light off another.
Why are you looking to cancel it? Do you have some secondary buffering, or are you using this method to pull and process data a byte at a time.
2017-06-15 08:29 AM
Updating this thread. My original post and other similar posts have been heard by the HAL developers.
New HAL functions were added recently for UARTs including;
/* Transfer Abort functions */
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
as of the time of this update, not all HAL series have been updated, but will be as each new series FW is released.
I will test HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart) in my original project shortly.