cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4_extenal_clock

alireza_roozitalab
Associate III
Posted on June 29, 2015 at 13:28

hello every one

i use stm32f429 micro controller and use external 8mhz oscillator as external clock src. and connect output frq of the oscillator to osc_in pin  and osc_out is floating.

every thing work correctly i use ltdc , eth , can , ... but i have problem with usart baud rate , it dose not work  correctly if i change clock src to hsi (in system_stm32f4xx.c) it worked correctly too  but if i use hse as clock src it dose not work. like baud rate has config problem . i check system clock by mco1 pin and its 180mhz (with hse config)

 
4 REPLIES 4
qwer.asdf
Senior
Posted on June 29, 2015 at 13:56

CubeMX clock tool can not find a solution for 180MHz clock using a 8MHz crystal. There must be some confusion. What are your PLLM, PLLN, PLLP, PLLQ values?

For example with these values below and a 8MHz crystal you can run at 168MHz.

PLLM = 5

PLLN = 210

PLLP = 2

PLLQ = 7

AHB prescaler = 1

APB1 prescaler = 4

APB2 prescaler = 2
John F.
Senior
Posted on June 29, 2015 at 14:42

If you are using the Std Periph Lib functions then setting the baud rate uses a call to RCC_GetClocksFreq. This function uses HSE_VALUE.

HSE_VALUE is a constant defined in stm32f4xx.h file (default value 25 MHz), user has to ensure that HSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may have wrong result.

Check what HSE_VALUE is defined as in your project.

Posted on June 29, 2015 at 15:09

And if you use the scope to measure the bit timing of the serial data how does this correlate with the rate programmed into the USART? What's the relationship here?

Review the source code for setting the baud rate. Print out the speeds the system thinks the AHB, APB1, APB2, etc are clocking at.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
alireza_roozitalab
Associate III
Posted on June 30, 2015 at 14:58

thanks for your replays

hse_value in stm32f4xx.h was 25000000 and i change it to 8000000 and every thing is true now