stm32f 查看系統(tǒng)時鐘配置
之前因為系統(tǒng)時鐘配置問題吃了很多虧,之前通過查看寄存器配置的形式進行時鐘的計算,查看時鐘配置是否正確,但是具體每個時鐘具體是多少還是需要進行計算的,后來發(fā)現(xiàn)在庫函數(shù)中有一個函數(shù)可以直接獲取系統(tǒng)時鐘,
* @brief Returns the frequencies of different on chip clocks.
* @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold
* the clocks frequencies.
* @note The result of this function could be not correct when using
* fractional value for HSE crystal.
* @retval None
*/
void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
參數(shù)如下
typedef struct
{
uint32_t SYSCLK_Frequency; /*!< returns SYSCLK clock frequency expressed in Hz */
uint32_t HCLK_Frequency; /*!< returns HCLK clock frequency expressed in Hz */
uint32_t PCLK1_Frequency; /*!< returns PCLK1 clock frequency expressed in Hz */
uint32_t PCLK2_Frequency; /*!< returns PCLK2 clock frequency expressed in Hz */
uint32_t ADCCLK_Frequency; /*!< returns ADCCLK clock frequency expressed in Hz */
}RCC_ClocksTypeDef;
通過調(diào)用這個函數(shù)就可以輕松達到查看系統(tǒng)時鐘的目的
RCC_ClocksTypeDef ClockInfo;
RCC_GetClocksFreq(&ClockInfo);
結(jié)果如下