AnsweredAssumed Answered

HAL_UART_Receive versus HAL_UART_Receive_IT

Question asked by von_ahnen.michael on Feb 6, 2017
Latest reply on Apr 19, 2018 by Joerg Wagner

I am using a Nucleo-L476RG board and I am trying to use the HAL_UART_Receive_IT function to receive a byte at a time from a RS-232 source (4800 Baud) on UART 4.  I need to use the interrupt because I am transmitting out on UART3 console data and I miss characters when I transmit long strings.  But I always get a framing error when I call the my receive function:


UART4_status = HAL_UART_Receive_IT(&huart4,(uint8_t *)rx_data, 1);


I don't see any framing errors when I poll for the data:


UART4_status = HAL_UART_Receive(&huart4,(uint8_t *)rx_data, 1, 1000);


Here the initialization of the UART generated by CubeMX:


/* UART4 init function */

static void MX_UART4_Init(void)



huart4.Instance = UART4;

huart4.Init.BaudRate = 4800;

huart4.Init.WordLength = UART_WORDLENGTH_8B;

huart4.Init.StopBits = UART_STOPBITS_1;

huart4.Init.Parity = UART_PARITY_NONE;

huart4.Init.Mode = UART_MODE_TX_RX;

huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart4.Init.OverSampling = UART_OVERSAMPLING_16;

huart4.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart4) != HAL_OK)







Before I try to receive data, I enable the RXNE interrupt:





I have attached the main.c.


Is there something I am missing on the interrupt initialization?