GD32F407入坑指南 第一章

1.资料下载

工欲善其事,必先利其器。

本系列教程采用keil5开发,使用GD32官方提供的固件库。

1.1 keil下载

keil下载网址:https://www.keil.com/download/product/

如果觉得官方下载的慢,可以用网盘下载。

链接:https://pan.baidu.com/s/18G26AvnDY2M73eV1BNVkTQ 
提取码:88gl

1.2 GD32资料下载

使用KEIL进行GD32开发,需要下载相应系列的芯片包以及官方提供的固件库。

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

GD32F4xx AddOn 是GD32F4系列的芯片支持包,GD32F4xx Firmware Library 是固件包,包含各种外设的驱动文件。

解压后如下,双击即可安装。

2.工程模版搭建

2.1 准备工作

解压GD32F4xx_Firmware_Library,如下:

 Docs中包含中英文版本的固件库使用指南。

 Examples中包含官方提供的各种外设的例程,在实际开发时可以进行参考。

 Firmware中包含的是官方的固件库,后续就是要将这里面的文件添加到工程中。

 Template中包含的是基础的例程,工程创建以此为基础。

 新建F407_Template工程模版文件夹,在文件下下件四个子文件夹,如下:

 将\GD32F4xx_Firmware_Library_V3.2.0\Firmware\CMSIS下的4个文件,拷贝到工程目录CORE中,

将\GD32F4xx_Firmware_Library_V3.2.0\Firmware\CMSIS\GD\GD32F4xx\Include 下的两个文件拷贝到工程目录CORE中,

将\GD32F4xx_Firmware_Library_V3.2.0\Firmware\CMSIS\GD\GD32F4xx\Source 中的system_gd32f4xx.c拷贝到工程目录CORE中,

将 \GD32F4xx_Firmware_Library_V3.2.0\Firmware\CMSIS\GD\GD32F4xx\Source\ARM中的3个启动文件拷贝到工程目录CORE中(其实只需要startup_gd32f407_427.s),至此工程目录CORE下所需要的文件就齐全了,共10个文件。

 将\GD32F4xx_Firmware_Library_V3.2.0\Firmware\GD32F4xx_standard_peripheral中的两个文件夹(外设头文件和源文件)全部拷贝到工程目录FWLIB文件夹下,

 将\GD32F4xx_Firmware_Library_V3.2.0\Template中的8个文件拷贝到工程目录USER中,

 将\GD32F4xx_Firmware_Library_V3.2.0\Template\Keil_project中的两个文件及文件夹拷贝到工程目录USER中。至此,工程所需的所有文件都齐全了,可以开始搞事情了。

 2.2 KEIL配置

打开KEIL,新建4个文件组

在User分组中添加如下3个文件

 在CMSIS分组中添加system_gd32f4xx.c文件

在Peripherals分组中添加外设的驱动文件,全部添加进来。

 在Startup分组中添加启动文件

 所有文件添加完成,打开main.c,注释掉无关代码,编译工程,有很多报错,提示找不到头文件,需要为添加的文件指定头文件路径。

添加头文件路径:

再次编译工程,至此工程模板创建成功。

 下一章,点灯验证工程模板。

### GD32F407VGT6 Microcontroller Development in KEIL Environment Setup For the GD32F407VGT6 microcontroller, which is based on the ARM Cortex-M4 core developed by GigaDevice Semiconductor Inc., setting up a development environment using KEIL involves several key configurations to ensure proper operation of the device. #### Installation and Configuration of KEIL MDK To begin with, installing KEIL MDK (Microcontroller Development Kit) software provides an integrated development platform that supports various ARM-based devices including those from Megadvice like the GD32 series[^1]. After installation: - **Project Creation**: Create a new project specifying the target as `GD32F4xx` family. - **Startup File Selection**: Choose appropriate startup files provided specifically for this chip model. These are typically found within the manufacturer’s library package or can be downloaded separately. #### Hardware Abstraction Layer (HAL) Library Integration Integrating HAL libraries simplifies peripheral control while ensuring portability across different platforms. For the GD32F407VGT6, these libraries facilitate easier access to hardware features without delving into low-level details. The official documentation often includes examples demonstrating how to integrate such libraries effectively. #### Debugging Tools Connection Connecting debugging tools like J-LINK or STLINK via SWD interface allows real-time monitoring and troubleshooting during code execution. Proper connection settings must match what has been configured inside KEIL under debug options. ```c // Example C Code Snippet Showing Basic LED Blinking Using GPIO Peripheral #include "gd32f4xx.h" int main(void){ rcu_periph_clock_enable(RCU_GPIOA); // Enable clock for GPIOA gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_8); while(1){ gpio_bit_set(GPIOA,GPIO_PIN_8); delay_1ms(500); gpio_bit_reset(GPIOA,GPIO_PIN_8); delay_1ms(500); } } ``` The above example demonstrates initializing peripherals through standard initialization functions available in the HAL library, followed by simple operations like toggling LEDs connected to specific pins.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值