cancel
Showing results for 
Search instead for 
Did you mean: 

HSI-PLL 64Mhz Problem

vcelik
Associate II
Posted on June 12, 2013 at 11:36

Hi,

I have STM32103C6 and my code goes well if I use HSE with PLL (72Mhz). But I try to have 64Mhz SYSCLK and HCLK using HSI. But every time when I am debugging, I see that after clock configuration, the code goes to HardFault_Handler. 

I know that before my main(), SystemInit() function (in system_stm32f10x.c file) is running. I commented out HSE freq definition like that: 

//&sharpdefine SYSCLK_FREQ_72MHz  72000000

My code is below. What is my mistake?

Thank You.

int main(void)

{

    RCC_PCLK1Config(RCC_HCLK_Div2);

    RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_16);

    RCC->CR |= RCC_CR_PLLON; //Enable PLL     

    while((RCC->CR & RCC_CR_PLLRDY) == 0) //Wait till PLL is ready 

    {;

    }    

    RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));// Select PLL as system clock source

    RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;        

    while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)// Wait till PLL is used as system clock source 

    {;

    }

    ...... 

}

#hsi-pll
1 REPLY 1
zzdz2
Associate II
Posted on June 12, 2013 at 12:11

I think you need to configure flash wait states, FLASH->ACR