cancel
Showing results for 
Search instead for 
Did you mean: 

spl RCC config for external oscillator

mahdi zamani
Associate II
Posted on July 30, 2017 at 10:57

hi 

i have connected &sharposcillator to &sharpOSC_IN (PD0) i used this function for init &sharpRCC at &sharpSTM32F103c8t6

but is not work with &sharppll and &sharpexternal oscillator please help to me ...

void RCC_Configuration(void){

ErrorStatus HSEStartUpStatus;

RCC_DeInit(); /// RCC system reset(for debug purpose)

RCC_HSEConfig(RCC_HSE_Bypass); /// Enable HSE

HSEStartUpStatus = RCC_WaitForHSEStartUp(); /// Wait till HSE is ready

if(HSEStartUpStatus == SUCCESS)

{

RCC_HCLKConfig(RCC_SYSCLK_Div1); /// HCLK = SYSCLK

RCC_PCLK2Config(RCC_HCLK_Div1); /// PCLK2 = HCLK

RCC_PCLK1Config(RCC_HCLK_Div2); /// PCLK1 = HCLK/2

RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /// PLLCLK = 8MHz * 9 = 72 MHz

RCC_PLLCmd(ENABLE); /* Enable PLL */

while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); /// Wait till PLL is ready

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

while(RCC_GetSYSCLKSource() != 0x08); /// Wait till PLL is used as system clock source

}

}

thanks 

mahdi

oscillator 

#uphill-skiing
7 REPLIES 7
Posted on July 30, 2017 at 15:53

If you have an XO that's on all the time, lose

HSEStartUpStatus = RCC_WaitForHSEStartUp(); /// Wait till HSE is ready

if(HSEStartUpStatus == SUCCESS)

Make sure you set the flash wait states before switching to the 72 MHz clock.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 01, 2017 at 12:29

sorry 

can give me example of this ?

Posted on August 01, 2017 at 20:12

Doesn't the SPL have a whole bunch of examples? Here's a quick cleanup of yours using the advice I provided..

void RCC_Configuration(void)
{
 RCC_DeInit(); /// RCC system reset(for debug purpose)
 RCC_HSEConfig(RCC_HSE_Bypass); /// Enable HSE, already on and hot
 FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // Enable Prefetch Buffer
 FLASH_SetLatency(FLASH_Latency_2); // Flash 2 wait state
 RCC_HCLKConfig(RCC_SYSCLK_Div1); /// HCLK = SYSCLK
 RCC_PCLK2Config(RCC_HCLK_Div1); /// PCLK2 = HCLK
 RCC_PCLK1Config(RCC_HCLK_Div2); /// PCLK1 = HCLK/2
 RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /// PLLCLK = 8MHz * 9 = 72 MHz
 RCC_PLLCmd(ENABLE); // Enable PLL
 while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); /// Wait till PLL is ready
 RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /// Select PLL as system clock source
 while(RCC_GetSYSCLKSource() != 0x08); /// Wait till PLL is used as system clock source
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

https://community.st.com/tags#/?tags=uphill%20skiing

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 02, 2017 at 21:35

omg

thanks

Turvey.Clive.002

Posted on August 04, 2017 at 12:31

Hello

I used the following function, but the problem persists and the controller is not loaded and the program does not run.

Should I look for something else for this bug?

In my samples, I did not see a comprehensive example of this!

Thankful
Posted on August 04, 2017 at 17:13

The Standard Peripheral Library v3.5.0 has a host of examples, the code to set clocks is typically in system_stm32f1xx.c

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-libraries/stsw-stm32054.html

 

Assuming you'd using something half-assed like CooCox?

Examples use Keil or IAR, and utilize CMSIS properly, whereby SystemInit() is called prior to main() to set up clocks and memory. The code in system_stm32f1xx.c should do whatever board specific work your board requires. The compiler should pass in a define identifying the class of STM32F1 device you are using.

Discuss specific of your board with its vendor, and review any schematics or other materials provided by them.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 22, 2017 at 13:42

My bug is hardware is not for programme