cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f030cc clock exception

Lyu.1
Associate III

platform: stm32f030cc

SDK: STM32F0xx_StdPeriph_Driver (V1.5.0)

Startup file: startup_stm32f030xc.s

Clock configuration: Since the HSE external pins are made as ordinary GPIO ports, HSI is used as the system clock source. The configuration is as follows:

0693W000000W2lSQAS.bmp

static void SetSysClock_test(void)
{
  __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
  
  /* SYSCLK, HCLK, PCLK configuration ----------------------------------------*/
    RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE |RCC_CFGR_HPRE|RCC_CFGR_SW| RCC_CFGR_PLLMULL));
    RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSI_DIV2 | RCC_CFGR_HPRE_DIV1|RCC_CFGR_SW_PLL | RCC_CFGR_PLLMULL12);
    RCC->CR |= ((uint32_t)RCC_CR_PLLON);
    /* Wait till PLL is ready */ 
    while((RCC->CR & RCC_CR_HSIRDY) == 0)
    {
    }
     /* Wait till PLL is ready */
    while((RCC->CR & RCC_CR_PLLRDY) == 0)
    {
    }
    
    
  /* Disable HSE */    
  RCC->CR &= ~((uint32_t)RCC_CR_HSEON);
  
   return;
}

phenomenon:Most of the time the program triggers hardfault in __main, there is a very small probability to enter main (), I suspect it is overclocking (96M?).. So I changed RCC_CFGR_PLLMULL12 to RCC_CFGR_PLLMULL6 ,but it appeared as follows:

phenomenon:

1. OS_CPU_SysTickInit (48000000ul / OS_TICKS_PER_SEC);(#Define OS_TICKS_PER_SEC 5000u) ,I found that the systick interrupt is triggered once for 400us.

2. When I set SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2 of SPI1, I found that the clock of spi1 is only 12M From this, it is determined that the system clock is only 24M.

What is the reason for this?

thank you very much!

10 REPLIES 10

Thank you very much for your answers, thank you for your selfless dedication.