2021-07-16 09:34 AM
I am using the UART4 in DMA mode. But as soon as I initialize the UART in RX mode, I get a framing error that calls the HAL_UART_ErrorCallback Error _Handler which halts the program. Below is my init code.
/* UART4 init function */
void UART4_Init(void)
{
UartReady = false;
huart4.Instance = UART4;
huart4.Init.BaudRate = 115200;
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)
{
Error_Handler();
}
UartReady = false;
GPIO_Set_RS485_TXEN(0);
HAL_UART_Receive_DMA( &huart4, UART_RX_Buffer, cmdLen);
}
The error occurs at the last line (HAL_UART_Receive_DMA().
How do I prevent this error?
Guidance appreciated....
Solved! Go to Solution.
2021-07-16 10:39 AM
Thanks Pavel. It was a hardware problem. works fine now.
2021-07-16 09:55 AM
Does framing error occur if you receive without DMA?
If yes, does it persist after 1st byte?
What if you just ignore framing errors in few first bytes?
--pa
2021-07-16 10:39 AM
Thanks Pavel. It was a hardware problem. works fine now.