调用库函数RCC_GetClocksFreq,该函数能够回来片上的各种时钟的频率
函数原形void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
RCC_ClocksTypeDef界说于文件“stm32f10x_rcc.h”:
typedef struct
{
uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency expressed in Hz */
uint32_t HCLK_Frequency; /*!< HCLK clock frequency expressed in Hz */
uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency expressed in Hz */
uint32_t PCLK2_Frequency; /*!< PCLK2 clock frequency expressed in Hz */
}RCC_ClocksTypeDef;
例:
/* Get the frequencies of different on chip clocks */
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
履行完后,直接检查RCC_Clocks,在各成员中取出所需求时钟频率就行了。