cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I am trying to communicate Uart in interrupt mode.We are able to successfully transmit & receive data to PC (through USB-UART).But when we connect to UART based modem then we are getting HAL_UART_ErrorCallback & transmission is failing. Pls help us.

PBira.1
Associate II

This error callback function is not getting called when we connect to PC. But we are getting during modem (UART based)communication only. Whats purpose of this callback ? Is there any configuration need to add ?

25 REPLIES 25

Are you sure?

Overrun is usually a receive error - meaning that you aren't processing the received data fast enough.

0693W000008yKMOQA2.pngPlease check attached snap where we are transmitting and receiving data between Modem and STM32.

Let us know what is best way to handle this receive buffer.

Surely the idea for using the IT methods would be that you can receive and transmit concurrently (full-duplex), not that you move the blocking loop into your main() loop.

Is RecvTick a volatile? Are you sure the spin loop isn't optimized out?

You really need to use the IT methods to manage buffers that you can then inspect and process asynchronously within your loop.

I'd freely admit the HAL UART implementation is a bit of a goat rodeo, but you can review the Reference Manual, and USART section to better understand the mechanics, and code something more effective.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello

In the above code if rx wait loop completed without timeout then NumStage will get the value 2 but this case "case 2:" never implemented .

0693W000008xsqBQAQ.pngNot as an image!

if(HAL_UART_Transmit_IT(&UartHandle, (uint8_t*)txbuff, TxBufLen)!= HAL_OK)
 {
    Error_Handler();
  }
  RecvTick = RESET;
 /*##-3- Wait for the end of the transfer #################################*/
  while (UartReady != SET && RecvTick++ < 50000)
  {
 
  }
  /* Reset transmission flag */
  UartReady = RESET;
  /*##-4- Put UART peripheral in reception process ###########################*/
  if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, 6) != HAL_OK)
  {
     Error_Handler();
  }
  RecvTick = RESET;
  /*##-5- Wait for the end of the transfer ###################################*/
  while (UartReady != SET && RecvTick++ < 50000)
  {
 
  }
  /* Reset transmission flag */
  UartReady = RESET;

This is snippet of code.