2013-06-12 02:36 AM
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 72000000My 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-pll2013-06-12 03:11 AM
I think you need to configure flash wait states, FLASH->ACR