###### tags: `火神板` # 火神板(NuMaker_Valcano) / Keil IDE ![](https://i.imgur.com/U3m0Wu9.png) #### 參考文章 * [【新唐 NuMaker-Volcano 评测】1、开箱及开发环境搭建](https://bbs.21ic.com/icview-3128418-1-1.html) * [新唐火神板開箱實作(一):NuMaker-Volcano與NuEclipse IDE入門篇](https://danchouzhou.blogspot.com/2021/03/numaker-volcanonueclipse-ide.html) * [官方介紹](https://www.nuvoton.com/board/numaker-volcano/) * [官方教學](https://www.nuvoton.com/board/numaker-volcano/?index=2) ## 本文開始 ### Spec * MCU: M0A23EC1AC * [官方說明](https://www.nuvoton.com/products/microcontrollers/arm-cortex-m0-mcus/m0a23-series/m0a23ec1ac/) * 賣點應該是耐高溫125度,所以叫火神 * 內建[CANBUS](https://zh.wikipedia.org/wiki/%E6%8E%A7%E5%88%B6%E5%99%A8%E5%8D%80%E5%9F%9F%E7%B6%B2%E8%B7%AF),主打車用? ### 安裝開發環境 * 下載與安裝 [KEIL MDK Nuvoton edition M0 / M23](http://www2.keil.com/nuvoton/M0-M23),輸入email等資料後,網頁上才會出現載點 ![](https://i.imgur.com/KvT3Sbr.png) * 下載與安裝 [Nuvoton Nu-Link Driver](https://www.nuvoton.com.cn/export/resource-files/Nu-Link_Keil_Driver_V3.07.7246r.zip),要裝在與Keil一樣的位置,如 C:\Keil_v5 * [新唐-IDE & 驅動程式-下載頁面](https://www.nuvoton.com/tool-and-software/ide-and-compiler/) * 下載與安裝 [開發板支援套裝軟體 (Board Support Package, BSP)](https://github.com/OpenNuvoton/M0A21BSP/archive/refs/heads/master.zip) * [新唐-開發板支援套件 (BSP)-下載頁面](https://www.nuvoton.com/tool-and-software/bsp/) * 建議所有東西都裝在同一個目錄,包含USB Driver ![](https://i.imgur.com/06TU1OT.png) * 在Win10環境下正常安裝的情況 ![](https://i.imgur.com/IAIHEiW.png) ### 指撥開關 * 上傳程式到板子上時 (注意指撥開關) ![](https://i.imgur.com/OWJG1GL.jpg) * 需要用到UART0時 (注意指撥開關) ![](https://i.imgur.com/BqTZSBg.jpg) ### Hello World * 開啟範例程式 (若Keil安裝順利,點兩下就會自動以Keil開啟) ![](https://i.imgur.com/F7JdilP.png) * 更新Nu-Link的韌體 (第一次才需要這個步驟) ![](https://i.imgur.com/a4epaMc.png) ![](https://i.imgur.com/VtFwct9.png) :::danger 按下Settings後,請跟著指示操作,我沒有截到圖。 ::: ![](https://i.imgur.com/xz5Svct.png) * 編譯 ![](https://i.imgur.com/y1ZILIq.png) * 上傳 (記得指撥開關) ![](https://i.imgur.com/0GKMfCS.png) * 用Putty查看結果 (記得指撥開關再撥回來) * Baud Rate: 115200 * 每按一次板子上的按紐,會印一次Hello World ![](https://i.imgur.com/MH91wLZ.png) ### Hello World Code (不用改) ```cpp= /****************************************************************************** * @file main.c * @version V1.00 * @brief A project template for M0A21 MCU. * * SPDX-License-Identifier: Apache-2.0 * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #include <stdio.h> #include "NuMicro.h" void UART_Open(UART_T *uart, uint32_t u32baudrate); void SYS_Init(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Enable HIRC clock (Internal RC 48MHz) */ CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk); /* Wait for HIRC clock ready */ CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk); /* Select HCLK clock source as HIRC and HCLK source divider as 1 */ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1)); /* Enable UART0 clock */ CLK_EnableModuleClock(UART0_MODULE); /* Switch UART0 clock source to HIRC */ CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART0SEL_HIRC, CLK_CLKDIV0_UART0(1)); /* Update System Core Clock */ SystemCoreClockUpdate(); /* Set PB multi-function pins for UART0 RXD=PB.6 and TXD=PB.4 */ SYS->GPB_MFP1 = (SYS->GPB_MFP1 & ~(SYS_GPB_MFP1_PB4MFP_Msk | SYS_GPB_MFP1_PB6MFP_Msk)) | \ (SYS_GPB_MFP1_PB4MFP_UART0_TXD | SYS_GPB_MFP1_PB6MFP_UART0_RXD); /* Lock protected registers */ SYS_LockReg(); } /* * This is a template project for M0A21 series MCU. Users could based on this project to create their * own application without worry about the IAR/Keil project settings. * * This template application uses external crystal as HCLK source and configures UART0 to print out * "Hello World", users may need to do extra system configuration based on their system design. */ int main() { SYS_Init(); /* Init UART0 to 115200-8n1 for print message */ UART_Open(UART0, 115200); /* Connect UART to PC, and open a terminal tool to receive following message */ printf("Hello World\n"); /* Got no where to go, just loop forever */ while(1); } /*** (C) COPYRIGHT 2017 Nuvoton Technology Corp. ***/ ```