2025-12-07 10:51 PM - last edited on 2025-12-08 12:15 AM by mƎALLEm
Hello,
I’m trying to transmit data at 2.5 Mbps (2500000 baud), but I’m not receiving any output. The same code works correctly at 2 Mbps, so the issue only appears when using 2.5 Mbps.
I tested both 64 MHz and 40 MHz clock configurations for the UART. At 64 MHz, CubeMX shows a warning:
“Real Baudrate set at BRR register is 2.461538 Mbits/sec. Error: -1.54%.”
Because of this error, I switched to a 40 MHz configuration, which gives the exact 2.5 Mbps baud rate—but I still don’t receive any data.
Is there any additional configuration required to make the MCU reliably transmit at 2.5 Mbps?
2025-12-07 10:56 PM - last edited on 2025-12-08 12:17 AM by mƎALLEm
These are the settings i have applied to uart at 2.5Mbps
static void MX_USART2_UART_Init(void)
{
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 2500000;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}