2015-09-09 02:02 AM
Hi,
I have read some of the previous related issues, but I am still confused. How do I use the uart interrupts in a correct way (using hal)? I need to receive each single character since don't know the length. I have modified the UART TwoBoards_ComIT example to a dummy rx application that doesn't do anything except beeing in receive mode. The application will get stuck if I send more than 3 characters(I tested from realTerm). Sending each character one by one works fine. while(1) { UartReady = RESET; if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, 1) != HAL_OK) { Error_Handler(); } while (UartReady != SET) { BSP_LED_On(LED2); HAL_Delay(100); BSP_LED_Off(LED2); HAL_Delay(100); BSP_LED_On(LED2); HAL_Delay(100); BSP_LED_Off(LED2); HAL_Delay(500); } } void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { UartReady = SET; }2015-09-09 02:43 AM
Hi Seed,
It is not so clear how ''The application will get stuck if you send more than 3 characters'':- at which level exactly?- are there any error flag set in USART registers?- isn't the problem root cause coming from transmitter side?-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-09-09 05:00 AM
Hi,
Sorry for the bad description of the problem. It does not get stuck. I get buffer overflow error reported in HAL_UART_IRQHandler and HAL_UART_ErrorCallback is called. If I send 3 bytes I get buffer overflow using receive size 1, but if I change the code below to receive 3 bytes(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, 3) ) I do not get buffer overflow. I will investigate futher, but I guess it is not reading fast enough and then I guess I need to modify hal implementation? Any suggestions? /Jonas2015-09-10 12:47 AM
Hi,
It seems like the hal implementation for uart IT not inted for the use case if you do not know the length of the reciving bytes. I will go for the DMA solution using circular buffer mode then I don't think I need to patch the hal implementation.