新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > stm32f407時鐘配置方法例程解析

        stm32f407時鐘配置方法例程解析

        作者: 時間:2016-11-24 來源:網絡 收藏

        /*到了這一步,我們已經配置好了系統時鐘,頻率為168MHz.下面我們可以對AHB,APB,外設等的時鐘進行配置*/

        /*時鐘的結構請參考用戶手冊*/

        /*首先配置AHB時鐘(HCLK).為了獲得較高的頻率,我們對SYSCLK 1分頻,得到HCLK*/

        RCC_HCLKConfig(RCC_HCLK_Div1);

        /*APBx時鐘(PCLK)由AHB時鐘(HCLK)分頻得到,下面我們配置PCLK*/

        /*APB1時鐘配置. 4分頻,即PCLK1 = 42 MHz*/

        RCC_PCLK1Config(RCC_HCLK_Div4);

        /*APB2時鐘配置. 2分頻,即PCLK2 = 84 MHz*/

        RCC_PCLK2Config(RCC_HCLK_Div2);

        /*****函數結束******/

        /*以上函數可以大體上說明這些庫函數的作用*/

        }

        對于 RCC_PLLConfig();函數,大家可能會迷惑。

        其函數原型為:

        void RCC_PLLConfig(uint32_t RCC_PLLSource,

        uint32_t PLLM,

        uint32_t PLLN,

        uint32_t PLLP,

        uint32_t PLLQ);

        迷惑的地方肯定在于后面4個參數PLLM / PLLN / PLLP / PLLQ.

        在庫函數源文件 system_stm32f4xx.c中可以找到這4個參數的說明,請看下圖注釋部分:

        (下面的是從 庫函數源文件 stm32f4xx_rcc.c 中找到的。其他函數可以直接去看庫函數,注釋非常詳細)

        /**

        * @brief Configures the main PLL clock source, multiplication and division factors.

        @簡介 配置主PLL時鐘源,以及分頻因子 (PLL不止一個,還有一個用來為音頻處理提供高質量時鐘)

        * @note This function must be used only when the main PLL is disabled.

        * @注意 這個函數只能在主PLL失能時才能使用

        * @param RCC_PLLSource: specifies the PLL entry clock source.

        @參數 RCC_PLLSource:選擇PLL時鐘源

        * This parameter can be one of the following values:

        這個參數可以是如下值:

        * @arg RCC_PLLSource_HSI: HSI oscillator clock selected as PLL clock entry

        選擇HSI作為PLL時鐘源

        * @arg RCC_PLLSource_HSE: HSE oscillator clock selected as PLL clock entry

        選擇HSE作為PLL時鐘源

        * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.

        *

        * @param PLLM: specifies the division factor for PLL VCO input clock

        @參數 PLLM:設置 PLL VCO 輸入時鐘的 除法因子(division factor)

        * This parameter must be a number between 0 and 63.

        這個參數 范圍是 0 ~ 63

        * @note You have to set the PLLM parameter correctly to ensure that the VCO input

        * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency

        * of 2 MHz to limit PLL jitter.

        * @注意 你需要正確選擇 PLLM的值, 使得 VCO輸入頻率 介于 1~2MHz.

        建議選擇 2MHz 來限制PLL震蕩(jitter?)

        * @param PLLN: specifies the multiplication factor for PLL VCO output clock

        * This parameter must be a number between 192 and 432.

        @參數 PLLN 選擇 PLL VCO輸出時鐘的 乘法因子(multiplication factor )

        這個參數的值 介于 192 ~432

        * @note You have to set the PLLN parameter correctly to ensure that the VCO

        * output frequency is between 192 and 432 MHz.

        * @注意 你學要正確選PLLN的大小,以保證VCO輸出時鐘介于 192 ~432MHz

        * @param PLLP: specifies the division factor for main system clock (SYSCLK)

        * This parameter must be a number in the range {2, 4, 6, or 8}.

        @參數 PLLP 選擇 系統時鐘SYSCLK 的除法因子(division factor ),這個

        值可以是2,4,6,8

        * @note You have to set the PLLP parameter correctly to not exceed 168 MHz on

        * the System clock frequency.

        * @注意 你需要正確設置PLLP,確保系統時鐘SYSCLK不超過168MHz

        * @param PLLQ: specifies the division factor for OTG FS, SDIO and RNG clocks

        * This parameter must be a number between 4 and 15.

        @參數 PLLQ 選擇給 OTG FS(USB), SDIO(SD卡讀寫), RNG(隨機數發生器)

        時鐘的除法因子,其值介于4~15

        * @note If the USB OTG FS is used in your application, you have to set the

        * PLLQ parameter correctly to have 48 MHz clock for the USB. However,

        * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work

        * correctly.

        * @注意 如果在你的程序中用到 USB OTG FS,你需要正確設置PLLQ,確保USB有

        48MHz的時鐘。但是對于SDIO,RNG需要一個小于或等于48MHz的時鐘

        * @retval None


        上一頁 1 2 下一頁

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 九江县| 嘉兴市| 敦煌市| 瑞金市| 福鼎市| 大石桥市| 衢州市| 蓝山县| 阿克| 微博| 济阳县| 石门县| 竹北市| 武平县| 屏南县| 巴东县| 南安市| 崇明县| 怀宁县| 保德县| 凉山| 油尖旺区| 合阳县| 珲春市| 时尚| 龙门县| 东乌| 沙坪坝区| 休宁县| 尼玛县| 平湖市| 巧家县| 盘锦市| 盐山县| 宣城市| 漳浦县| 雷州市| 炎陵县| 龙口市| 万年县| 望城县|