2021-10-25 05:08 AM
Hi,
I'm using STM32CubeMx to generate UART initialisation code for STM32H743 controller. I'm able to test UART communication for baud rate 3686400.
I'm not able to make UART communication up & running when I changed baud rate to 4000000.
Is there other clock configurations to be changed to support UART baud rate of 4000000 ?
2021-10-25 05:26 AM
The OVER8 allows for higher rates, but it's predicated on a) the APB clock source (perhaps alternate peripherals clock mappable) and b) integer divisibility by 8 or 16.
As speed increases the granularity of the divisor becomes predominant in the % clock error (actual vs desired). Send repetitive 0x55 ('U') character and scope signal to confirm timing.
Async serial is also not particularly robust. For tightly packed data consider 2 stop bits to aid resync. Going to want to use DMA to service UART.
2021-10-26 01:01 AM
I see below initialisation sequence for UART2. Do you suggest to change huart2.Init.OverSampling = UART_OVERSAMPLING_8 ?
------------------------------------------ UART2_init ---------------------
huart2.Instance = USART2;
huart2.Init.BaudRate = 4000000;
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;
HAL_UART_Init(&huart2);
HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8);
HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8);
HAL_UARTEx_DisableFifoMode(&huart2);