UART receive interrupt issue HAL_UART_Receive_IT remains BUSY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-29 7:27 AM
Hi ,
I am using
HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL api for uart receive interrupt
i am calling it at end of HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
it works for some time
but after some time HAL_UART_Receive_IT return value is Busy
once its busy ,its always busy , i tried below options
- if it's busy ,try again. But still remains busy
if((HAL_UART_Receive_IT(&UartHandle, (uint8_t *)RxBuffer, 1)) != HAL_OK)
{
HAL_UART_Receive_IT(huart, (uint8_t *)RxBuffer, 1) ;
}
2 . I used while loop ,still remains busy forever
if((HAL_UART_Receive_IT(&UartHandle, (uint8_t *)RxBuffer, 1)) != HAL_OK)
{
while(HAL_UART_Receive_IT(huart, (uint8_t *)RxBuffer, 1)==HAL_BUSY);
}
3 . I used timer to ensure a delay after which i try to enable receive interrupt again after 5 sec ,
still remain busy .
4 . I tried running this operation in between __disable_irq() and __enable_irq,still problem remains same.
How to resolve the issue ?
- Labels:
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-29 7:58 AM
The transfer needs to complete in order for it to go from busy to ready. Ensure data is being sent to it. Ensure you're not within an ISR which is blocking it from completing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-29 8:15 AM
I used __disable_irq() and __enable_irq also but result remains same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-29 8:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-30 2:40 AM
Check if you are using HAL_UART_Transmit() in polling and HAL_UART_Receive_IT() in inteerupt mode. Use bot Tx and Rx in Interrupt mode. Older ST Driver has shared variables between Tx and Rx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-30 3:29 AM
I am using Transmit only ,i will try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-30 4:43 AM
How to get newer drivers ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-02 5:07 PM
Sounds like a buffer overrun issue most likely due to you being in another interrupt or you're still in the HAL_UART_RxCpltCallback() when another character is received.
Someone had posted in the forums saying after a while when reading a text file that gets updated every so often, that person was looking for a key word. Well that code would not always find the key word. It turns out that person was processing the received data within the interrupt instead of saving the data to a buffer and processing the data from a polling routine outside of the interrupt.
If you are indeed processing the received data within the interrupt, then you should make a ring buffer to save the data and then parse the data outside the interrupt.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-12 3:44 AM
I am buffering characters till i receive a '\r' inside HAL_UART_RxCpltCallback() function .
an i am calling parser function from inside of HAL_UART_RxCpltCallback() function . Is it OK ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-13 3:58 PM
That is why you're having issues. When you're calling another function from within the HAL_UART_RxCpltCallback(), you're no longer receiving interrupts when characters are filling the FIFO, thus you're getting a buffer overrun. You should set a flag that indicates your buffer is ready to be parsed. Then poll outside of any interrupts for that flag and then parse the buffer.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
