最近有一项目,综合比较下各方面,选择了STM32F100 的片子,也是现学现用,今天想做个SysTick的精准延时,发现新的固件库(3.0的貌似)中SysTick的函数和旧 的不一样了,新的函数库中只有SysTick_Config()这个函数了,而里面的系统时钟貌似只有
//以下为选择CPU的运行频率,系统已经默认了用户是使用8M的晶振了.
//#define SYSCLK_FREQ_HSE HSE_Value //这个值系统默认为8M
//#define SYSCLK_FREQ_20MHz 20000000
//#define SYSCLK_FREQ_36MHz 36000000
//#define SYSCLK_FREQ_48MHz 48000000
#define SYSCLK_FREQ_56MHz 56000000
//#define SYSCLK_FREQ_72MHz 72000000
这几种,然后新库函数中提供的定义如下:
/*******************************************************************************
* Clock Definitions
*******************************************************************************/
#ifdef SYSCLK_FREQ_HSE
const uint32_t SystemFrequency = SYSCLK_FREQ_HSE; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_HSE; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_HSE; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = SYSCLK_FREQ_HSE; /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_HSE; /*!< APB Peripheral bus 2 (high) speed */
#elif defined SYSCLK_FREQ_20MHz
const uint32_t SystemFrequency = SYSCLK_FREQ_20MHz; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_20MHz; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_20MHz; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = SYSCLK_FREQ_20MHz; /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_20MHz; /*!< APB Peripheral bus 2 (high) speed */
#elif defined SYSCLK_FREQ_36MHz
const uint32_t SystemFrequency = SYSCLK_FREQ_36MHz; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_36MHz; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_36MHz; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = SYSCLK_FREQ_36MHz; /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_36MHz; /*!< APB Peripheral bus 2 (high) speed */
#elif defined SYSCLK_FREQ_48MHz
const uint32_t SystemFrequency = SYSCLK_FREQ_48MHz; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_48MHz; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_48MHz; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = (SYSCLK_FREQ_48MHz/2); /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_48MHz; /*!< APB Peripheral bus 2 (high) speed */
#elif defined SYSCLK_FREQ_56MHz
const uint32_t SystemFrequency = SYSCLK_FREQ_56MHz; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_56MHz; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_56MHz; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = (SYSCLK_FREQ_56MHz/2); /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_56MHz; /*!< APB Peripheral bus 2 (high) speed */
#elif defined SYSCLK_FREQ_72MHz
const uint32_t SystemFrequency = SYSCLK_FREQ_72MHz; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = SYSCLK_FREQ_72MHz; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = SYSCLK_FREQ_72MHz; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = (SYSCLK_FREQ_72MHz/2); /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = SYSCLK_FREQ_72MHz; /*!< APB Peripheral bus 2 (high) speed */
#else /*!< HSI Selected as System Clock source */
const uint32_t SystemFrequency = HSI_Value; /*!< System Clock Frequency (Core Clock) */
const uint32_t SystemFrequency_SysClk = HSI_Value; /*!< System clock */
const uint32_t SystemFrequency_AHBClk = HSI_Value; /*!< AHB System bus speed */
const uint32_t SystemFrequency_APB1Clk = HSI_Value; /*!< APB Peripheral bus 1 (low) speed */
const uint32_t SystemFrequency_APB2Clk = HSI_Value; /*!< APB Peripheral bus 2 (high) speed */
#endif
我的问题是,STM32F100的 最大频率只有24M,在这里要怎么选择呢 ?
看了网上有人试验过,说只有在选择56M 的时候SysTick延时稳定,但STM32F100最大只有24M,选56M 的话这算正常工作么?
有点不解,所以还请论坛各位朋友帮忙看看。。
香主可以讲讲么? |