/** * system_stm32f10x.c — Minimal system init for sensorless BLDC project * * Clock config (72MHz HSE+PLL) is handled by HW_SystemClock_Config() in bldc_hw.c * This file only provides CMSIS-required symbols. */ #include "stm32f10x.h" /** @addtogroup STM32F10x_System_Private_Variables * @{ */ uint32_t SystemCoreClock = 72000000; /** @addtogroup STM32F10x_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit(void) { /* Reset the RCC clock configuration to the default reset state (HSI) */ RCC->CR |= (uint32_t)0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; /* Configure Flash latency */ *(volatile uint32_t *)0x40022000 = 0x00000012; /* Set SystemCoreClock to HSI (8MHz) initially; HW_SystemClock_Config() will set to 72MHz */ SystemCoreClock = 8000000; } void SystemCoreClockUpdate(void) { /* Read current clock configuration and update SystemCoreClock */ SystemCoreClock = 72000000; }