cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L100C Discovery clock after reset

kozlovdmn
Associate II
Posted on December 09, 2015 at 16:22

I've started to look for the answer for the following question after finding out the problem with UART. It did not work correctly, and I tried to change baud rate from 115200 to 57600. After that UART worked.

I use SystemCoreClock variable and after updating it gets value 32M. But in accordance to UART baud rate actual clock value is 16M.

I use startup_stm32lxx_mpd.s code, which calls SystemInit -> SetSysClock. It tries to set PLL(HSE) as clock source. But STM32L-DISCO doesn't have external source by default.

It's strange, but after init process register shows that PLL is used and clock frequency is 32MHz.

If not to use SystemInit clock source is MSI with frequency about 2 MHz as datasheet claims.

How can it happen?

ANSWER:

Set the HSEBYP before HSEON. (see comments below)

#stm32l100 #clock #systeminit
2 REPLIES 2
Posted on December 09, 2015 at 16:28

The USARTs typically run of the APB (Peripheral Bus) which is running at some fractional rate wrt the core.

Most of the DISCO series boards derive an 8 MHz clock source from the ST-LINK portion of the circuit. It outputs 8 MHz via it's MCO pin, and this enters as an HSE source rather than an oscillator.

Check the schematic/manual for your specific board.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
kozlovdmn
Associate II
Posted on December 09, 2015 at 17:35

I thought ST-LINK resonator was disconnected. There is a mistake in text in manual. But schematic is correct. 

Thank you clivel .

The problem is, that startup library suppose external resonator to be used. But actually, ST-LINK block provides external clock source. So correct mode should be selected by setting the HSEBYP before setting HSEON.