2017-08-17 04:05 AM
hello
i use stm32f030f4 and use 10MHz oscillator (BYPASS) and i want achieve to 48mhz in mcu.
and i use STDPERIPH_DRIVER and keil v5.what configuration i have to do ?what code i have to add to my project?
Solved! Go to Solution.
2017-08-17 12:00 PM
RCC_HSEConfig(RCC_HSE_ON); becomes RCC_HSEConfig(RCC_HSE_Bypass); and you don't need to wait for it to start
or something along these lines in system_stm32f0xx.c, called via SystemInit()
static void SetSysClock(void)
{/******************************************************************************/
/* HSE BYPASS used as System clock source *//******************************************************************************//* SYSCLK, HCLK, PCLK configuration ----------------------------------------*/
/* Enable HSE BYPASS */ RCC->CR |= ((uint32_t)RCC_CR_HSEBYP);/* Enable Prefetch Buffer and set Flash Latency */
FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;/* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;/* PCLK = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE_DIV1;/* Select HSE as system clock source */
RCC->CFGR = (RCC->CFGR | (uint32_t)((uint32_t)~(RCC_CFGR_SW))) | (uint32_t)RCC_CFGR_SW_HSE;/* Wait till PLL is used as system clock source */
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_HSE);}2017-08-17 04:38 AM
You'd need to modify the clock/pll setting code in system_stm32f0xx.c
Not sure the available multiplier and divider settings will get you from 10 MHz to 48 MHz, review the setting options in the reference manual.
2017-08-17 06:52 AM
If i want get 10MHz to 10 mhz what code i have to add?
i dont know how enable bypass.
2017-08-17 10:49 AM
Hi,
HSE 10MHz input frequency does not allow you to get the 48MHz SYSCLK with PLL.
HSE PREDIV is between 1 and 16PLLMul is between 2 and 16But you can with a HSE frequncy of 8MHz or 12MHz
For 8Mhz PLL Input:
HSE_PREDIV = 1PLL_MUL = 6For 12Mhz PLL Input:
HSE_PREDIV = 1PLL_MUL = 4BR
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-08-17 12:00 PM
RCC_HSEConfig(RCC_HSE_ON); becomes RCC_HSEConfig(RCC_HSE_Bypass); and you don't need to wait for it to start
or something along these lines in system_stm32f0xx.c, called via SystemInit()
static void SetSysClock(void)
{/******************************************************************************/
/* HSE BYPASS used as System clock source *//******************************************************************************//* SYSCLK, HCLK, PCLK configuration ----------------------------------------*/
/* Enable HSE BYPASS */ RCC->CR |= ((uint32_t)RCC_CR_HSEBYP);/* Enable Prefetch Buffer and set Flash Latency */
FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;/* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;/* PCLK = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE_DIV1;/* Select HSE as system clock source */
RCC->CFGR = (RCC->CFGR | (uint32_t)((uint32_t)~(RCC_CFGR_SW))) | (uint32_t)RCC_CFGR_SW_HSE;/* Wait till PLL is used as system clock source */
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_HSE);}