一、简介
EWARM,即 IAR Embedded Workbench for ARM,是由 IAR Systems 开发的一款专门用于 ARM 微处理器软件开发的集成开发环境。以下是具体介绍:
- 功能特性:
- 完整工具链支持:集成了高级编辑器、全面的编译器工具链以及功能强大的调试器,支持从编码、编译、调试到固件下载的完整开发周期。
- 多核心支持:支持多种 ARM 核心,如 Cortex-M、Cortex-R 等,还为不同的 ARM 内核和硬件平台提供了一系列预设的项目模板,可针对不同处理器进行优化编译。
- 实时操作系统兼容:支持多种 RTOS,包括 FreeRTOS、RT-Thread、uC/OS 等,方便开发者在多任务或高实时性要求的应用场景中进行开发。
- 调试功能:
- 丰富调试接口:支持 JTAG 调试,也可使用 SWD 接口,方便开发者访问微控制器的内部资源,如寄存器、内存和外设等,以进行实时调试和分析。
- 多种调试手段:内置的调试器提供了断点、步进、单步、变量观察和寄存器查看等功能,还支持事件追踪、数据追踪和地址追踪等多种追踪模式,以及代码覆盖率分析和性能分析等功能,有助于开发者发现程序瓶颈并优化程序性能。
- 主要模块:
- 编译器:高度优化的 IAR ARM C/C++ Compiler,具有先进的通用编译器优化和针对特定处理器的速度优化及存储器优化功能。
- 链接器:一个通用的 IAR XLINK Linker,可将编译后的目标文件链接成可执行文件或库文件。
- 建库程序和运行库:IAR XAR 和 XLIB 建库程序用于创建和管理库文件,IAR DLIB C/C++ 运行库提供了运行时所需的函数支持。
- 调试器:IAR C-SPY 调试器是一款先进的高级语言调试器,支持源代码和反汇编程序调试,具备复杂的代码和数据断点、丰富的数据监视功能等。
- 其他:还包括项目管理器、功能强大的编辑器以及命令行实用程序等。
- 优势特点:
- 入门容易:相较于其他一些 ARM 开发环境,EWARM 具有较为友好的操作界面和相对简单的配置流程,开发者能够较快上手,适合初学者使用。
- 代码紧凑:通过其优化的编译器和相关工具,生成的代码具有较高的效率,代码体积相对较小,能够更好地适应嵌入式系统对资源有限的特点。
- 跨平台支持良好:从软件模拟器到高性能的硬件调试器,EWARM 提供了广泛的目标设备支持,可在不同的开发环境和硬件平台上使用。
二、EWARM(IAR)安装过程
1.点击运行安装程序
2.选择第1个选项安装IAR FOR ARM(对于ARM架构的)
3.NEXT
4.accept,NEXT
5.选择安装路径(建议C盘以外,最好新建一个不含有中文的文件夹,因为后续有些版本不支持中文路径),下一步
6.驱动
7.下一步
8.确定
9.安装
10.等待安装完成
11.暂时不打开软件,暂时取消证书的安装
12.驱动无脑装
这是 TI Emulators 8.0.803.0(德州仪器仿真器软件)的安装许可协议界面,核心内容是:
1. 界面功能
- 呈现 德州仪器(Texas Instruments)的软件许可协议,要求你阅读并决定是否接受条款。
- 协议里有版权、使用限制、责任等法律约束内容(2004 年 3 月 11 日版本 )。
2. 操作选项
- 接受协议(I accept the agreement):选这个才能继续安装,代表你同意遵守协议条款。
- 不接受(I do not accept the agreement):选这个会终止安装,无法使用软件。
简单说,就是安装前让你确认 “是否同意德州仪器的软件使用规则”,想装软件就得选 “接受”,点 “Next” 继续流程;不想装就选 “不接受” 或直接关窗口~
这是 TI Emulators 8.0.803.0(德州仪器仿真器软件) 的安装路径设置界面,核心信息是:
1. 标题含义
“Code Composer Studio Installation Directory”:需指定软件安装路径,若和 Code Composer Studio(CCS,德州仪器的集成开发环境)一起用,要选对应 CCS 版本(ccsv5/6/7)的文件夹。
2. 路径说明
- 默认路径是
C:\ti
,你可以修改成其他自定义路径(点输入框右侧文件夹图标选位置)。 - 若已有 CCS,按提示选到 CCS 安装目录里的
ccsv5
/ccsv6
/ccsv7
文件夹,能让仿真器和 CCS 更好配合。
3. 操作逻辑
选好路径后点 “Next” 继续安装;想改路径就调整输入框内容;不想装了点 “Cancel” 退出。
简单说,就是让你选 “把 TI 仿真器软件装到电脑哪个位置”,按需求(或默认)设好路径,继续下一步安装流程~
13.打开运行,准备安装证书
取消
14.到help下的License manager
15.点击License下的离线激活
16.注册机
17.将注册机的License Number,放到离线激活里,然后,离线激活里再点击下一步
18.NO
19.选择存放初始证书的位置,后面再使用这个产生一个回应的验证证书
20.确认下一步
21.使用注册机去使用初始证书,产生一个回应的验证证书(真正的证书)
选择初始证书
点击产生
22.回到注册页面,选择回应文件
23.后续
这是 IAR License Manager(IAR 许可证管理器) 的弹窗,对应 IAR Embedded Workbench for Arm 8.32
版本,核心内容是:
1. 功能说明
你的许可证允许提取 IAR Library Source for Arm(ARM 库源代码包),这些代码可辅助开发,但提取需要管理员权限(确保系统级操作权限)。
2. 操作选项
- Yes:立即提取库源代码,点了之后会触发管理员权限申请(可能弹 UAC 确认框),完成后把代码放到指定路径。
- No:暂不提取,之后想提随时能在许可证管理器里操作;若勾选
Don't notify me about this again
,下次不会再弹这个提示。
3. 建议逻辑
- 若开发时需要调试 / 查看库代码(比如做底层优化、排错),选 Yes 提取,方便后续开发;
- 若只是简单用 IAR 编译、不碰库源码,选 No 也不影响基础功能。
简单说,就是 “许可证给你权限提取 ARM 库源码,要不要现在用管理员权限提取”,按需选就行~
我选的yes
24.绿色状态,完成
三、初步新建IAR下的GD32工程模板
注:硬件平台:立创梁山派
1.到GD32的官网下载固件库和IAR环境支持包(环境补丁)
2.安装IAR补丁,一定一定要以管理员身份运行才能让其自动检测到你安装的IAR路径!!!
3.新建工程文件夹IAR_GD32_Template
4.\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library下的Firmware里就是外设源文件,但是,首先,在我们的工程文件夹里新建文件夹
5.搬移文件
(1)CMSIS
\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Firmware\CMSIS的core内核文件放到CMSIS
(2)StartUp
IAR环境启动文件
\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Firmware\CMSIS\GD\GD32F4xx\Source\IAR下的启动文件放到StartUp
(3)SYSTEM
\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Firmware\CMSIS\GD\GD32F4xx下的头文件放到SYSTEM的INCLUDE
\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Firmware\CMSIS\GD\GD32F4xx\Source下的system_gd32f4xx.c放到SYSTEM的SOURCE
(4)USER
同时根据官方例程需要一些其他文件支持,在\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Template寻找
根据自己习惯,分个类
(5)GD32F4xx_standard_peripheral
\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library_V3.3.1\GD32F4xx_Firmware_Library\Firmware\GD32F4xx_standard_peripheral
将外设源文件全放到GD32F4xx_standard_peripheral
6.打开IAR,创建IAR工程
7.跟keil就差不多了,就是新建组别,添加文件
8.工程配置
(1)右击项目,选择Options
(2)选芯片
(3)配置库,内核文件已有CMSIS
设置外部文件夹Debug
(4)添加宏,路径
USE_STDPERIPH_DRIVER,GD32F4XX,LV_CONF_INCLUDE_SIMPLE
下拉选择相对路径:
(5)输出配置
(6)选择下载模式
差点忘记立创梁山派用的DAP了
(7)选择链接文件
Linker --> Config --> Linker configuration file 勾选上 Override default 重设默认文件
9.编译
保存工作空间
10.解决报错
Building configuration: IAR_GD32 - Debug
Updating build tree...
0 file(s) deleted.
Updating build tree...
startup_gd32f450_470.s
gd32f4xx_exmc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_dbg.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_enet.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_dci.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_dma.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_dac.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_crc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_can.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_ctc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_adc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_misc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_i2c.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_pmu.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_fwdgt.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_exti.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_ipa.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_fmc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_it.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_gpio.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_iref.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_wwdgt.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_tli.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_rcu.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_rtc.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_sdio.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_spi.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_syscfg.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_usart.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_timer.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
gd32f4xx_trng.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
main.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
systick.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
system_gd32f4xx.c
Fatal Error[Pe035]: #error directive: "Please select the target GD32F4xx device in gd32f4xx.h file" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\SYSTEM\Include\gd32f4xx.h 56
Error while running C/C++ Compiler
Total number of errors: 33
Total number of warnings: 0
添加具体的芯片的宏
Building configuration: IAR_GD32 - Debug
Updating build tree...
1 file(s) deleted.
Updating build tree...
startup_gd32f450_470.s
gd32f4xx_exmc.c
gd32f4xx_can.c
gd32f4xx_ctc.c
gd32f4xx_dbg.c
gd32f4xx_dma.c
gd32f4xx_dci.c
gd32f4xx_crc.c
gd32f4xx_enet.c
gd32f4xx_dac.c
gd32f4xx_adc.c
gd32f4xx_exti.c
gd32f4xx_i2c.c
gd32f4xx_pmu.c
gd32f4xx_misc.c
gd32f4xx_fmc.c
gd32f4xx_gpio.c
gd32f4xx_fwdgt.c
gd32f4xx_rcu.c
gd32f4xx_it.c
gd32f4xx_ipa.c
gd32f4xx_iref.c
main.c
Fatal Error[Pe1696]: cannot open source file "gd32f450i_eval.h" E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\USER\Source\main.c 39
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\USER\Source\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\CMSIS\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\GD32F4xx_standard_peripheral\Include\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\GD32F4xx_standard_peripheral\Source\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\StartUp\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\SYSTEM\Include\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\SYSTEM\Source\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\USER\Include\"
searched: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\Project\..\USER\Source\"
searched: "D:\IAR Systems\Embedded Workbench 8.2\arm\inc\"
searched: "D:\IAR Systems\Embedded Workbench 8.2\arm\inc\c\"
current directory: "E:\EWARM_Projects\EWARM_Examples_Workspaces\IAR_GD32\IAR_GD32_Template\USER\Source"
Error while running C/C++ Compiler
gd32f4xx_wwdgt.c
gd32f4xx_rtc.c
gd32f4xx_trng.c
gd32f4xx_syscfg.c
gd32f4xx_tli.c
gd32f4xx_sdio.c
gd32f4xx_spi.c
gd32f4xx_usart.c
gd32f4xx_timer.c
systick.c
system_gd32f4xx.c
Total number of errors: 1
Total number of warnings: 0
方法1:
添加上去gd32f450i_eval.c/h
方法二:
重写main.c,不用#include "gd32f450i_eval.h"
11.代码改正
gd32f4xx_it.c
注释led_spark();
/*!
\file gd32f4xx_it.c
\brief interrupt service routines
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
*/
/*
Copyright (c) 2024, 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 "gd32f4xx_it.h"
#include "main.h"
#include "systick.h"
/*!
\brief this function handles NMI exception
\param[in] none
\param[out] none
\retval none
*/
void NMI_Handler(void)
{
/* if NMI exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles HardFault exception
\param[in] none
\param[out] none
\retval none
*/
void HardFault_Handler(void)
{
/* if Hard Fault exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles MemManage exception
\param[in] none
\param[out] none
\retval none
*/
void MemManage_Handler(void)
{
/* if Memory Manage exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles BusFault exception
\param[in] none
\param[out] none
\retval none
*/
void BusFault_Handler(void)
{
/* if Bus Fault exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles UsageFault exception
\param[in] none
\param[out] none
\retval none
*/
void UsageFault_Handler(void)
{
/* if Usage Fault exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles SVC exception
\param[in] none
\param[out] none
\retval none
*/
void SVC_Handler(void)
{
/* if SVC exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles DebugMon exception
\param[in] none
\param[out] none
\retval none
*/
void DebugMon_Handler(void)
{
/* if DebugMon exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles PendSV exception
\param[in] none
\param[out] none
\retval none
*/
void PendSV_Handler(void)
{
/* if PendSV exception occurs, go to infinite loop */
while(1) {
}
}
/*!
\brief this function handles SysTick exception
\param[in] none
\param[out] none
\retval none
*/
void SysTick_Handler(void)
{
//led_spark();
delay_decrement();
}
main.h
注释void led_spark(void);
/*!
\file main.h
\brief the header file of main
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
*/
/*
Copyright (c) 2024, 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.
*/
#ifndef __MAIN_H
#define __MAIN_H
/* led spark function */
//void led_spark(void);
#endif /* __MAIN_H */
main.c
/*!
\file main.c
\brief led spark with systick
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
*/
/*
Copyright (c) 2024, 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 "gd32f4xx.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
//#include "gd32f450i_eval.h"
int main(void)
{
systick_config();
// 开启时钟
rcu_periph_clock_enable(RCU_GPIOD);
/* 配置为输出模式 */
gpio_mode_set(GPIOD,GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_7);
/* 配置为推挽输出 50MHZ */
gpio_output_options_set(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_7);
gpio_bit_set(GPIOD, GPIO_PIN_7);
while(1)
{
gpio_bit_write(GPIOD, GPIO_PIN_7, RESET);
delay_1ms(100);
gpio_bit_write(GPIOD, GPIO_PIN_7, SET);
delay_1ms(100);
}
}
///*!
// \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(LED1);
// } else {
// gd_eval_led_off(LED1);
// }
//
// 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
//
// gd_eval_led_init(LED1);
// systick_config();
//
//#ifdef __FIRMWARE_VERSION_DEFINE
// fw_ver = gd32f4xx_firmware_version_get();
// /* print firmware version */
// printf("\r\nGD32F4xx 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 */
//
// while(1) {
// }
//}
//
//#ifdef GD_ECLIPSE_GCC
///* retarget the C library printf function to the USART, in Eclipse GCC environment */
//int __io_putchar(int ch)
//{
// usart_data_transmit(EVAL_COM0, (uint8_t)ch);
// while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));
// return ch;
//}
//#else
///* retarget the C library printf function to the USART */
//int fputc(int ch, FILE *f)
//{
// usart_data_transmit(EVAL_COM0, (uint8_t)ch);
// while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));
//
// return ch;
//}
//#endif /* GD_ECLIPSE_GCC */
编译没有问题
12.下载
注意:由于IAR对于DAP支持较差,可能出问题,需要重新设置一下DAP
参考链接:H7-TOOL的高速DAPLINKY用于IAR9.30的设置说明(2022-06-18) - H7-TOOL开发工具 - 硬汉嵌入式论坛 - Powered by Discuz!
DAP下载失败问题的解决方法:
(1)DAP开启
(2)这里建议选择Software和Hardware,我选的Software成功
勾选
(3)接口模式SWD
我成功了
13.成功,演示过程
点OK
点GO,不打断点,全速运行
四、实验效果
工程链接:
https://github.com/Molesidy/GD32.githttps://github.com/Molesidy/GD32.git
参考链接(如有侵权,请联系删除):
IAR for ARM下载、安装、注册,并搭建stm32工程(胎教版)
H7-TOOL的高速DAPLINKY用于IAR9.30的设置说明(2022-06-18) - H7-TOOL开发工具 - 硬汉嵌入式论坛 - Powered by Discuz!