GD32 RCU — 系统时钟切换

GD32 GD32F30x_Firmware_Library V3.0.3 RCU 系统时钟切换 示例教学

RCU — 系统时钟切换

固件库: GD32F30x_Firmware_Library V3.0.3
芯片: GD32
源文件: GD32F30x_Firmware_Library_V3.0.3/Examples/RCU/System_clock_switch/main.c


功能简介

本示例演示 RCU 的基本用法。

完整代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "gd32f30x.h"
#include "gd32f307c_eval.h"
#include <stdio.h>

int main(void)
{
    gd_eval_com_init(EVAL_COM0);
    printf("\r\nCK_SYS switch test demo\r\n");

    /* disable the USART */
    usart_disable(EVAL_COM0);

    /* switch system clock to 36MHz by HXTAL */
    switch_system_clock_to_36m_hxtal();
    gd_eval_com_init(EVAL_COM0);

    /* print out the clock frequency of system */
    printf("\r\nCK_SYS is %d", rcu_clock_freq_get(CK_SYS));
    _delay(1000);

    /* switch system clock to 72MHz by IRC8M */
    switch_system_clock_to_72m_irc8m();
    gd_eval_com_init(EVAL_COM0);

    /* print out the clock frequency of system */
    printf("\r\nCK_SYS is %d", rcu_clock_freq_get(CK_SYS));
    while(1){
    }
}

代码讲解

printf 输出:通过串口打印调试信息。需要先调用 uart_print_init 完成重定向。

世界是你们
使用 Hugo 构建
主题 StackJimmy 设计