cancel
Showing results for 
Search instead for 
Did you mean: 

HSI clock and baudrate ?

antonius
Senior

Dear Members,

I changed my clock from MSI to HSI but my SPI and UART baudrate becoming wrong,

What do I miss here ?

thanks

29 REPLIES 29
S.Ma
Principal

Only you can answer a question with so little details, except Sherlock maybe?

Not good for me, it's not supported for STM32LX series :(

If you change clocks on ​the fly, you'll have to change dividers dependent on them also.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior

0690X000008A1dtQAC.jpgyes what value for divider ?

the setting for UART3

:

void MX_USART3_UART_Init(void)

{

 huart3.Instance = USART3;

 huart3.Init.BaudRate = 115200;

 huart3.Init.WordLength = UART_WORDLENGTH_8B;

 huart3.Init.StopBits = UART_STOPBITS_1;

 huart3.Init.Parity = UART_PARITY_NONE;

 huart3.Init.Mode = UART_MODE_TX_RX;

 huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart3.Init.OverSampling = UART_OVERSAMPLING_16;

 if (HAL_UART_Init(&huart3) != HAL_OK)

 {

   Error_Handler();

 }

}

antonius
Senior

clock

0690X000008A1dyQAC.jpg

S.Ma
Principal

What do you want to do? Use HSI through PLL and generate the same SYSCLK 2.097 MHz default MSI frequency?

I want to use 16MHz HSI, but SPI2 and UART3 are misconfigured , working on 2.097MHz but not on HSI 16MHz, by the time I have 16MHz

any clues or same experiences ? thanks

antonius
Senior

I put on 32MHz, only USART3 can not work properly

I make :

   USART3->BRR = 32000000/115200;

Correct me ?0690X000008A1g4QAC.jpg

///

void MX_USART3_UART_Init(void)

{

 // Configure BRR by deviding the bus clock with the baud rate

 huart3.Instance = USART3;

 huart3.Init.BaudRate = 115200;

 huart3.Init.WordLength = UART_WORDLENGTH_8B;

 huart3.Init.StopBits = UART_STOPBITS_1;

 huart3.Init.Parity = UART_PARITY_NONE;

 huart3.Init.Mode = UART_MODE_TX_RX;

 huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart3.Init.OverSampling = UART_OVERSAMPLING_16;

   USART3->BRR = 32000000/115200;

 if (HAL_UART_Init(&huart3) != HAL_OK)

 {

   Error_Handler();

 }

}