2018-05-03 07:13 AM
Hello,
I am sending requests continuously via TCP/IP using my client application. Requests are send with 200 ms interval.
When a request come I am trying to send request to my peripheral and expect an answer, but sometimes UART remain busy(Error Handler occurs when waiting for HAL_UART_STATE_READY) and communication fail. I would like to ask you if I am doing something wrong. Thank you very much.
Here is my function for inquiring result from periph:
void Inquire_result (uint8_t TxBuffer[2])
{ int Timeout = 1000000; while(huart3.gState != HAL_UART_STATE_READY) { Timeout--; if(Timeout == 0) Error_Handler(); } Timeout = 1000000; if(HAL_UART_Transmit_IT(&huart3, (uint8_t*)TxBuffer, 2) != HAL_OK) { Error_Handler(); } while(huart3.RxState != HAL_UART_STATE_READY) { Timeout--; if(Timeout == 0) Error_Handler(); } Timeout = 1000000; if(HAL_UART_Receive_IT(&huart3, (uint8_t*)aRxBuffer, 4) != HAL_OK) { Error_Handler(); } while(DataRecieved == 0) { Timeout--; if(Timeout == 0) Error_Handler(); }}And here are my callback functions:
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
{ /* Set transmission flag: transfer complete */ HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_RESET); DataRecieved = 0;}void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{ /* Set transmission flag: transfer complete */ HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET); DataRecieved = 1;}And my interrupt priorities:
/* Ethernet peripheral interrupt init */
HAL_NVIC_SetPriority(ETH_IRQn, 2, 0); HAL_NVIC_EnableIRQ(ETH_IRQn);/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 1, 0);/* USART3 interrupt Init */
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART3_IRQn);#rs-232 #raw-lwip #stm32f-uart #uart-interrupt2018-05-03 02:04 PM
Error Handler occurs
Why? From where is it called?
JW
2018-05-04 01:56 AM
Mostly it occurs within this waiting loop after transmission:
if(HAL_UART_Transmit_IT(&huart3, (uint8_t*)TxBuffer, 2) != HAL_OK)
{ Error_Handler(); } while(huart3.RxState != HAL_UART_STATE_READY) { Timeout--; if(Timeout == 0) Error_Handler(); //mostly it occurs here }Aplication seems working fine for some time (I have about 10 valid results), but suddently communication freezes when error handler occurs.
2018-05-06 08:51 AM
I don't use Cube, so don't quite understand what this means, but couldn't this be because the device which is connected through UART does not answer as expected? What's there? Do you monitor the UART Tx and Rx lines, e.g. by a logic analyzer?
JW