cancel
Showing results for 
Search instead for 
Did you mean: 

Bug: UART->BRR not set correct if Sampling is 8 (STM32F4 Lib version V1.4.0)

dirk2399
Associate
Posted on September 25, 2015 at 12:38

The Code (generated by mxcube)

void MX_USART6_UART_Init(void)
{
huart6.Instance = USART6;
huart6.Init.BaudRate = 3000000;
huart6.Init.WordLength = UART_WORDLENGTH_8B;
huart6.Init.StopBits = UART_STOPBITS_1;
huart6.Init.Parity = UART_PARITY_NONE;
huart6.Init.Mode = UART_MODE_TX_RX;
huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart6.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&huart6);
}

do not set the BRR register correct. With PCLK1 = 42MHz and PCLK2 = 84MHz Brr is 0x1C If i change the code from

#define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) ((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4)|(UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x0F))

to

#define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) ((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 
4
)|((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x0F)>>1))

Brr is 0x16 Can some one fix this bug. #stm32f4-uart-brr-sampling-8
1 REPLY 1
Nesrine M_O
Lead II
Posted on March 11, 2016 at 13:12

Hi bruenig.dirk,

The  issue of the wrong BRR calculation in oversampling by 8 is fixed in firmware package STM32CubeF4 V1.11.0.

Thank you very much for your contribution to the enhancement of our STM32 related solutions.

-Syrine-