2012-10-24 08:49 AM
I use an external 8.0 Mhz crystal connected to the HSE pins. I use STM32F2xx_Clock_Configuration_V1.1.0.xls utility with HSE_OSC setting to 8.0 MHz and HCLK setting to 120.0 MHz and let generate the file system_stm32f2xx.c .
In my application I output some text on the USART2.
Sometimes when I power up my system it is working normally so my text is output with the correct baud rate. In other cases powering up the system the text is output with a much lower baud.
I have programmed the MCO2 pin, so that it is outputting the signal SYSCLK divided by two. In the cases when my system is working normally I measure on this pin with the scope 60 MHz. In other cases when the system is working abnormally, then I measure there 8.0 MHz.
It seems that something is going wrong with the PLL setup in the cases, when my system is working abnormally.
On the GUI of the STM32F2xx_Clock_Configuration_V1.1.0.xls utility they state that it is for RevB and RevY silicon. Actually I have RevX silicon. Is this the cause of my problem that the utility doesn’t support RevX silicon ?
2012-10-24 09:02 AM
Perhaps your external crystal isn't starting properly, and it defaults to HSI.
Instead of focusing on the XLS you should look at the code running on the STM32F2, which usually with the CMSIS libraries is in the system_stm32f2xx.c file and in SystemInit(). Understand the code flow, the enabling of the HSE, and PLL, and investigate why either of those isn't working. Baud rates are a strong indicator of a discrepancy in HSE_VALUE wrt to the physical value. Make sure it's not set to 25000000, and reflects the external component.2012-10-26 02:25 AM
I was able to solve my problem
There is I timeout in the routine SetSysClock where it waits getting HSE oscillator ready. This timeout was too short for my crystal. So the code was sometimes setting HSI oscillator as backup clock.