一、安装GD32 Embedded Builder开发环境

兆易创新GigaDevice-资料下载兆易创新GD32 MCU

二、GD32 Embedded Builder界面汉化

注意:该软件需要安装JDK

2.1 Help --> Install New Software

2.2 点击Add

2.3 输入如下地址

https://mirrors.ustc.edu.cn/eclipse/technology/babel/update-site/R0.20.0/2022-12/

2.4 找到简体中文包进行下载

2.5 后续点击相信,最后重启

三、基于立创·GD32VW553开发板的点灯代码

3.1 点击新建项目

3.2 选C

3.3 该芯片架构是RISC-V

3.4 选芯片HMQ7,笔者的MCU是这样的

3.5 这里的编译链工具看自己选择哪种

3.6 led需要高电平点亮,同时注释掉所有示例代码

以及中断的示例代码

3.7 写点灯代码,点击左上角锤子按钮编译(如果你有使用过STM32CubeIDE,那就很轻车熟路了。)

/*!
    \file    main.c
    \brief   led spark with systick, USART print and key example

    \version 2025-01-16, V1.4.0, firmware for GD32VW55x
*/

/*
    Copyright (c) 2025, GigaDevice Semiconductor Inc.

    Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this
       list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    3. Neither the name of the copyright holder nor the names of its contributors
       may be used to endorse or promote products derived from this software without
       specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/

#include "gd32vw55x.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
#include "gd32vw553h_eval.h"



int bsp_led_init(void)
{
	//使能时钟
	rcu_periph_clock_enable(RCU_GPIOC);

	//设置输出模式 一般输出是浮空 不需要上下拉除非特殊情况
	gpio_mode_set(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_13);

	//输出模式下的输出能力设置推挽输出
	gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO_PIN_13);

	//初始化置高电平 使其熄灭
	gpio_bit_write(GPIOC, GPIO_PIN_13, RESET);
}

int bsp_led_toggle(void)
{
	gpio_bit_write(GPIOC, GPIO_PIN_13, SET);
	delay_1ms(1000);

	gpio_bit_write(GPIOC, GPIO_PIN_13, RESET);
	delay_1ms(1000);

}

int main(void)
{
	//一定要配置时钟
	systick_config();

	//这里的中断优先级分组可要可不要
	eclic_priority_group_set(ECLIC_PRIGROUP_LEVEL3_PRIO1);

	//led初始化
	bsp_led_init();

	while(1)
	{
		bsp_led_toggle();
	}
	return 0;
}








































///*!
//    \brief      toggle the led every 500ms
//    \param[in]  none
//    \param[out] none
//    \retval     none
//*/
//void led_spark(void)
//{
//    static __IO uint32_t timingdelaylocal = 0U;
//
//    if(timingdelaylocal) {
//
//        if(timingdelaylocal < 500U) {
//            gd_eval_led_on(LED2);
//            gd_eval_led_on(LED3);
//        } else {
//            gd_eval_led_off(LED2);
//            gd_eval_led_off(LED3);
//        }
//
//        timingdelaylocal--;
//    } else {
//        timingdelaylocal = 1000U;
//    }
//}
//
///*!
//    \brief      main function
//    \param[in]  none
//    \param[out] none
//    \retval     none
//*/
//int main(void)
//{
//#ifdef __FIRMWARE_VERSION_DEFINE
//    uint32_t fw_ver = 0;
//#endif /* __FIRMWARE_VERSION_DEFINE */
//
//    /* configure systick */
//    systick_config();
//    eclic_priority_group_set(ECLIC_PRIGROUP_LEVEL3_PRIO1);
//    /* initilize the LEDs, USART and key */
//    gd_eval_led_init(LED1);
//    gd_eval_led_init(LED2);
//    gd_eval_led_init(LED3);
//    gd_eval_com_init(EVAL_COM0);
//    gd_eval_key_init(KEY_TAMPER_WAKEUP, KEY_MODE_GPIO);
//
//#ifdef __FIRMWARE_VERSION_DEFINE
//    fw_ver = gd32vw55x_firmware_version_get();
//    /* print firmware version */
//    printf("\r\nGD32VW55X series firmware version: V%d.%d.%d", (uint8_t)(fw_ver >> 24), (uint8_t)(fw_ver >> 16), (uint8_t)(fw_ver >> 8));
//#endif /* __FIRMWARE_VERSION_DEFINE */
//
//    /* print out the clock frequency of system, AHB, APB1 and APB2 */
//    printf("\r\nCK_SYS is %d\r\n", rcu_clock_freq_get(CK_SYS));
//    printf("\r\nCK_AHB is %d\r\n", rcu_clock_freq_get(CK_AHB));
//    printf("\r\nCK_APB1 is %d\r\n", rcu_clock_freq_get(CK_APB1));
//    printf("\r\nCK_APB2 is %d\r\n", rcu_clock_freq_get(CK_APB2));
//
//    while(1) {
//        if(RESET == gd_eval_key_state_get(KEY_TAMPER_WAKEUP)) {
//            delay_1ms(50);
//            if(SET == gd_eval_key_state_get(KEY_TAMPER_WAKEUP)) {
//                gd_eval_led_toggle(LED1);
//            }
//        }
//    }
//}

3.8 烧录程序,长按boot的同时短按reset,然后松开,点击工具的Connect
串口烧录方式下载烧录工具: GD32AllInOneProgrammer

选了bin文件就点DOWNLOAD

四、实验效果

Logo

智能硬件社区聚焦AI智能硬件技术生态,汇聚嵌入式AI、物联网硬件开发者,打造交流分享平台,同步全国赛事资讯、开展 OPC 核心人才招募,助力技术落地与开发者成长。

更多推荐