美文网首页
GD32 切换系统时钟源

GD32 切换系统时钟源

作者: 骑上我心爱的小蜗牛 | 来源:发表于2020-08-27 11:00 被阅读0次

    切换到system_gd32fxxx.c(如:system_gd32f403.h),然后将以下程序

    /* system frequency define */
    #define __IRC8M           (IRC8M_VALUE)            /* internal 8 MHz RC oscillator frequency */
    #define __HXTAL           (HXTAL_VALUE)            /* high speed crystal oscillator frequency */
    #define __SYS_OSC_CLK     (__IRC8M)                /* main oscillator frequency */
    
    /* select a system clock by uncommenting the following line */
    /* use IRC8M */
    //#define __SYSTEM_CLOCK_IRC8M                    (uint32_t)(__IRC8M)
    //#define __SYSTEM_CLOCK_48M_PLL_IRC8M            (uint32_t)(48000000)
    //#define __SYSTEM_CLOCK_72M_PLL_IRC8M            (uint32_t)(72000000)
    //#define __SYSTEM_CLOCK_108M_PLL_IRC8M           (uint32_t)(108000000)
    //#define __SYSTEM_CLOCK_120M_PLL_IRC8M           (uint32_t)(120000000)
    //#define __SYSTEM_CLOCK_168M_PLL_IRC8M           (uint32_t)(168000000)
    
    /* use IRC48M */
    //#define __SYSTEM_CLOCK_168M_PLL_IRC48M          (uint32_t)(168000000)
    
    /* use HXTAL(XD series CK_HXTAL = 8M, CL series CK_HXTAL = 25M) */
    //#define __SYSTEM_CLOCK_HXTAL                    (uint32_t)(__HXTAL)
    //#define __SYSTEM_CLOCK_48M_PLL_HXTAL            (uint32_t)(48000000)
    //#define __SYSTEM_CLOCK_72M_PLL_HXTAL            (uint32_t)(72000000)
    //#define __SYSTEM_CLOCK_108M_PLL_HXTAL           (uint32_t)(108000000)
    //#define __SYSTEM_CLOCK_120M_PLL_HXTAL           (uint32_t)(120000000)
    #define __SYSTEM_CLOCK_168M_PLL_HXTAL           (uint32_t)(168000000)
    

    更换成

    /* system frequency define */
    #define __IRC8M           (IRC8M_VALUE)            /* internal 8 MHz RC oscillator frequency */
    #define __HXTAL           (HXTAL_VALUE)            /* high speed crystal oscillator frequency */
    #define __SYS_OSC_CLK     (__IRC8M)                /* main oscillator frequency */
    
    /* select a system clock by uncommenting the following line */
    /* use IRC8M */
    #define __SYSTEM_CLOCK_IRC8M                    (uint32_t)(__IRC8M)
    //#define __SYSTEM_CLOCK_48M_PLL_IRC8M            (uint32_t)(48000000)
    //#define __SYSTEM_CLOCK_72M_PLL_IRC8M            (uint32_t)(72000000)
    //#define __SYSTEM_CLOCK_108M_PLL_IRC8M           (uint32_t)(108000000)
    //#define __SYSTEM_CLOCK_120M_PLL_IRC8M           (uint32_t)(120000000)
    //#define __SYSTEM_CLOCK_168M_PLL_IRC8M           (uint32_t)(168000000)
    
    /* use IRC48M */
    //#define __SYSTEM_CLOCK_168M_PLL_IRC48M          (uint32_t)(168000000)
    
    /* use HXTAL(XD series CK_HXTAL = 8M, CL series CK_HXTAL = 25M) */
    //#define __SYSTEM_CLOCK_HXTAL                    (uint32_t)(__HXTAL)
    //#define __SYSTEM_CLOCK_48M_PLL_HXTAL            (uint32_t)(48000000)
    //#define __SYSTEM_CLOCK_72M_PLL_HXTAL            (uint32_t)(72000000)
    //#define __SYSTEM_CLOCK_108M_PLL_HXTAL           (uint32_t)(108000000)
    //#define __SYSTEM_CLOCK_120M_PLL_HXTAL           (uint32_t)(120000000)
    //#define __SYSTEM_CLOCK_168M_PLL_HXTAL           (uint32_t)(168000000)
    

    即,将#define __SYSTEM_CLOCK_168M_PLL_HXTAL 注释掉,更换成#define __SYSTEM_CLOCK_IRC8M即可将系统时钟源更换成内部的8M时钟。

    • 目前只知道这些,待补齐。

    相关文章

      网友评论

          本文标题:GD32 切换系统时钟源

          本文链接:https://www.haomeiwen.com/subject/tqhcsktx.html