AnsweredAssumed Answered

Problem with stm32f100c6 clock configuration

Question asked by amer.sherif on Jul 16, 2012
Latest reply on Nov 17, 2012 by Ahmad.Ibrahim
Hi everybody!

I'm using STM32F100C6 with IAR Embedded Workbench IDE and i'm trying to configure the system clock.

First i tried to use the external oscillator HSE that's built on the board, 20MHz, here's the code related:
       /* Enable the HSE */
       RCC_HSEConfig(RCC_HSE_ON);

       /* Wait till HSE is ready and if Time out is reached exit */
       HSEStartUpStatus = RCC_WaitForHSEStartUp();
       while(HSEStartUpStatus == ERROR)
       {}

The problem is that it stays there forever!

So i made some search for other way to deliver the 24 MHz that i need in my application and i found that i can use the HSI.
Here's the code related:

    /* Reset the RCC clock configuration to the default reset state */
    RCC_DeInit();

    /* Enable Internal High Speed oscillator */
    RCC_HSICmd(ENABLE);

    /* Configure HCLK such as HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1);

    /* Configure PCLK2 such as PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1);

    /* Configure PCLK1 such as PCLK1 = HCLK */
    RCC_PCLK1Config(RCC_HCLK_Div1);

    /* Set PLL clock output to 24MHz using HSI (8MHz) as entry clock */
    RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_6);

    /* Enable the PLL */
    RCC_PLLCmd(ENABLE);

    /* Select the PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

I made a check after that to see how the code affected the system clock:
    RCC_ClocksTypeDef RCC_Clocks;
    RCC_GetClocksFreq(&RCC_Clocks);

System clock, HCLK, PCLK1 and PCLK2 are 8MHz

Any help in that please?

Thanks in advance!

Outcomes