AnsweredAssumed Answered

STM32F107VC How to set up an Clock with HSE

Question asked by crazzolara.felix on Dec 20, 2015
Latest reply on Dec 20, 2015 by Clive One
Hello everyone 

I have an Evaluation Board from Thailand (No example projects found), with an STM32F107VC. Now I'd like to select the on board 25MHz oscillator as clock-source.

As it is the first time for me to set up a Clocksource I tried to make the code on my own and to compare it with the code produced by the STMCubeMX. The thing is, I actually dont want to use the Cube as I dont like the HAL-Library. Furthermore I want to learn how to make it myself, where the Standard Peripheral Library fits better in my Ideas.

Here is the Code i wrote myself:

     //Flash Settings
     //Enable HSE, Pre-Div's and PLL's and Flags
     while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET) {}
     while(RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {}
     while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}

Sadly the product wasnt that good. Several register as the RCC_CR, CFGR or the CFGR2 have been set wrong. Wrong means for example PREDIV1 was 5 instead of 8 and so on.

Id be really thankful if someone could tell me what is wrong with my code and perhaps explain what the correct order is to set up the register. Another thing Id like to know is, if it is necessary to check the flags if I enable the HSE or the PLL. I have seen projects from other people where they checked either one or the other flag. 

Strange was also that the Cube enabled me the PLL3 but I dont use this dude, do I?

Finally, when do I have to enable the ADC or DMA clock. Can I do this afterwards?