2020-02-20 07:07 PM
What am I doing wrong, or is it a bug in the HAL library?
Generated a project with CubeMX, with USART6, FIFO enabled.
When I call HAL_UART_Receive_IT, interrupt of the USART does not occur. No interrupt at all.
Then I change in MX_USART6_UART_Init HAL_UARTEx_EnableFifoMode to HAL_UARTEx_DisableFifoMode - and HAL_UART_Receive_IT begins working.
Of course, with buffer size > FIFO threshold size,
HAL_UART_Transmit_IT works well with FIFO enabled, the USART_ISR_TXE_TXFNF interrupt occurs.
Looked in the source, cannot find any error. ????
-- pa
2020-02-21 12:38 AM
Which version of HAL library? There are changes between 1.3 and 1.6 that I struggled with. In 1.6 it was necessary to set up fifo as below to get the interrupts working. Note the settings of the FIFO thresholds.
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.Init.ClockPrescaler = UART_PRESCALER_DIV2;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
SystemError=1;Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
SystemError=1;Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
SystemError=1;Error_Handler();
}
if (HAL_UARTEx_EnableFifoMode(&huart1) != HAL_OK)
{
SystemError=1;Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
2020-02-21 04:46 PM
Version 1.5 with Atollic. Have not tried 1.6 yet.
The fifo initialization code looks precisely as your example.
One difference is that I have
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
huart1.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;
because of another issue I see with 'H743/753: if overrun detection is enabled and overrun occurs (started type in terminal too early) then even synchronous read fails, it cannot clear overrun and recover.
And USART6 instead of USART1,
So, does HAL_UART_Receive_IT work for you?
-- pa
2020-02-23 02:44 PM
Verified also with CubeIDE and library v 1.6.
The difference is that with and without FIFO HAL_UART_Receive_IT enables different interrupt bits.
* with FIFO it sets USART_CR3_RXFTIE in CR3
* without FIFO it sets USART_CR1_RXNEIE_RXFNEIE in CR1.
In the former case, the interrupt never occurs (I set breakpoint on top level handler), no matter how many characters are received.
In the latter case, the interrupt occurs when every character is received,
So, there are three possibilities.
-- pa
2020-03-11 06:52 PM
Release notes for H7 cube library v 1.7.0 have something about USART RTO flag handling.
The RN section, by the way, refers to v. 1.8 which is not available to public yet.
Maybe it is a library bug fixed in v 1.8.
-- pa