系統(tǒng)從上電復(fù)位到72mz配置好之前,提供時鐘的是內(nèi)如高速rc振蕩器提供8MZ的頻率,這個由下面void SystemInit (void)函數(shù)的前面的一部分代碼來完成的和保證的:
RCC->CR |= (uint32_t)0x00000001;
本文引用地址:http://m.butianyuan.cn/article/201611/322423.htm
#ifndef STM32F10X_CL
RCC->CFGR &= (uint32_t)0xF8FF0000;
#else
RCC->CFGR &= (uint32_t)0xF0FF0000;
#endif
RCC->CR &= (uint32_t)0xFEF6FFFF;
RCC->CR &= (uint32_t)0xFFFBFFFF;
RCC->CFGR &= (uint32_t)0xFF80FFFF;
#ifdef STM32F10X_CL
RCC->CR &= (uint32_t)0xEBFFFFFF;
RCC->CIR = 0x00FF0000;
RCC->CFGR2 = 0x00000000;
#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
RCC->CIR = 0x009F0000;
RCC->CFGR2 = 0x00000000;
#else
RCC->CIR = 0x009F0000;
#endif
#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL)
#ifdef DATA_IN_ExtSRAM
SystemInit_ExtMemCtl();
#endif
#endif
接著void SystemInit (void)調(diào)用 SetSysClock();函數(shù),將系統(tǒng)時鐘配置到72m,將AHB,APB1,APB2等外設(shè)之前的時鐘都配置好,然后切換到72mz下運行。所以在使用哪個外設(shè)的時候,只需要使能相應(yīng)的外設(shè)時鐘就可以了
評論