AnsweredAssumed Answered

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

Question asked by bruenig.dirk on Sep 25, 2015
Latest reply on Mar 11, 2016 by Nesrine M
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.

Outcomes