cancel
Showing results for 
Search instead for 
Did you mean: 

HSI Clock Configuraion

sherif
Associate II
Posted on January 28, 2013 at 22:38

Hi,

I'm using stm32f10xc4, low density value line, it supports an HSE of 8 MHz, my hardware has 20 MHz which is wrong and that's the reason why the clock configuration doesn't go properly - i guess -.

So i tried to get the HSI through the PLL, the target is to reach 24MHz.

Here's my code, but it still doesn't work!

/* Enable Internal High Speed oscillator */

RCC_HSICmd(ENABLE);

/* Set PLL clock output to 24MHz using HSI (8MHz) as entry clock */

RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_6);

/* Select the PLL as system clock source */

RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

/* Enable the PLL */

RCC_PLLCmd(ENABLE);

/* Output PLL clock divided by 2 on MCO pin */

RCC_MCOConfig(RCC_MCO_PLLCLK_Div2);

/* Configure HCLK such as HCLK = SYSCLK */

RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* Configure PCLK1 such as PCLK1 = HCLK/2 */

RCC_PCLK1Config(RCC_HCLK_Div1);

/* Configure PCLK2 such as PCLK2 = HCLK */

RCC_PCLK2Config(RCC_HCLK_Div1);

/* Configure ADCCLK such as ADCCLK = PCLK2/2 */

RCC_ADCCLKConfig(RCC_PCLK2_Div2);

The while(1) inside main contains this:

GPIO_WriteBit(GPIOB, GPIO_Pin_0, Bit_SET);

GPIO_WriteBit(GPIOB, GPIO_Pin_0, Bit_RESET);

to measure the frequency, i'm exposing PB.0 to scope.

I tried to use this one but didn't work out either, gave me an unavailable item when watched.

RCC_ClocksTypeDef RCC_Clocks;

RCC_GetClocksFreq(&RCC_Clocks);

Any idea?

Thanks

#hsi #stm32 #clock
2 REPLIES 2
Posted on January 29, 2013 at 01:08

Like waiting for the HSI to start (probably already started as the chip uses it at reset)

Waiting for the PLL to lock.

Waiting for the source selection to be used.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 29, 2013 at 01:37

An HSE of 20 MHz also should not stop the part from working. Although you'll probably be limited to running at 10 or 20 MHz, as the PLL is not flexible enough to get you to 24 MHz, and 30 MHz is too fast, although I suspect the part will run up there.

The clocks are normally setup in SystemInit() in system_stm32f10x.c, which is normally part of CMSIS Library based projects.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..