一、簡介
IAR官網
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, thislist 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 documentationand/or other materials provided with the distribution.3. Neither the name of the copyright holder nor the names of its contributorsmay be used to endorse or promote products derived from this software withoutspecific 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, thislist 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 documentationand/or other materials provided with the distribution.3. Neither the name of the copyright holder nor the names of its contributorsmay be used to endorse or promote products derived from this software withoutspecific 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, thislist 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 documentationand/or other materials provided with the distribution.3. Neither the name of the copyright holder nor the names of its contributorsmay be used to endorse or promote products derived from this software withoutspecific 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新建工程模塊及工程配置 - GWen9 - 博客園
IAR for ARM下載、安裝、注冊,并搭建stm32工程(胎教版)
IAR的工程路徑和頭文件路徑的配置問題
H7-TOOL的高速DAPLINKY用于IAR9.30的設置說明(2022-06-18) - H7-TOOL開發工具 - 硬漢嵌入式論壇 - Powered by Discuz!