STM32F205 - UART5 Interrupt handler fail to receive interrupt
Hi all, Thanks for the support and sharing the experience.
I have generated the code using STM32 CubeMx and using UART5 in interrupt mode. UART5 interrupt is configured to receive interrupt for every 1byte of data reception. Snap of the code is below.
Observation : UART interrupt handler function call stop after start some time
Kindly verify that UART interrupt function is implemented without any violation.
int main(void)
{
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CAN1_Init();
MX_CAN2_Init();
MX_I2C1_Init();
MX_I2C2_Init();
MX_SPI1_Init();
MX_TIM4_Init();
MX_UART4_Init();
MX_UART5_Init();
MX_TIM10_Init();
MX_USART6_UART_Init();
MX_TIM14_Init();
MX_RTC_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT (&huart4, &g__MAIN_UART4_RxByte, DEF_MAIN_UART4_RX_BUFFER_SIZE);
HAL_UART_Receive_IT (&huart6, &g__MAIN_UART6_RxByte, DEF_MAIN_UART6_RX_BUFFER_SIZE);
//This method is to configure the UART5 Receiver in the non-blocking mode
HAL_UART_Receive_IT(&huart5, &g__MAIN_UART5_RxByte, DEF_MAIN_UART5_RX_BUFFER_SIZE);
}
void UART5_IRQHandler(void)
{
HAL_UART_IRQHandler(&huart5);
}
void HAL_UART_RxCpltCallback (UART_HandleTypeDef * huart)
{
if(huart->Instance == UART4)
{
//<Function call to store the received data>
HAL_UART_Receive_IT (&huart4, &g__MAIN_UART4_RxByte, DEF_MAIN_UART4_RX_BUFFER_SIZE);
}
if(huart->Instance == USART6)
{
//<Function call to store the received data>
HAL_UART_Receive_IT (&huart6, &g__MAIN_UART6_RxByte, DEF_MAIN_UART6_RX_BUFFER_SIZE);
}
if(huart->Instance == UART5)
{
//<Function call to store the received data>
HAL_UART_Receive_IT (&huart5, &g__MAIN_UART5_RxByte, DEF_MAIN_UART5_RX_BUFFER_SIZE);
}
}
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
if(huart->Instance == USART6)
{
}else if(huart->Instance == UART4)
{
}else if(huart->Instance == UART5)
{
if(HAL_UART_GetError(huart) != HAL_UART_ERROR_NONE)
{
nErrorCode = HAL_UART_GetError(huart);
State = HAL_UART_GetState(huart);
}
}
}Additional Info:
I required to receive GPS data over UART (\r\n+QGPSGNMEA: $GPGGA,060418.00,1257.506345,N,07744.637410,E,1,03,3.0,889.6,M,-85.0,M,,*4F\r\n) periodically every 500millisecond and other messages as well.
