9G-CM0 新唐CM0+MDK-ARM入门开发过程简介

一,准备MDK-ARM + 新唐CM0软件包

1,在https://www.mcu123.com/news/Soft/embsof/arm/201006/529.html
    下载RealView MDK-ARM 4.12 (MDK-ARM V4.12,MDK4.12)
 mdk412_mcu123.rar
 在https://www.mcu123.com/news/Soft/ShowSoftDown.asp?UrlID=3&SoftID=529
 右击“下载地址:”后的“下载”选择“目标另存为”下载文件到本地硬盘。
 (自己查找破解文件“keygen.exe”)
 https://esoft.mcu123.com/MCU123_temp_20100103@/arm/mdk412_mcu123.rar

2,在https://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=403a9c50-52c2-4463-9057-2595190602c5
 上下载 “NUC1xx Keil ICE driver (Build 3814) V1.01.zip”
 NUC1xxKeilICEdriverBuild3814V101.zip
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Documents/NUC1xxKeilICEdriverBuild3814V101.zip
    
 下载“NUC1xx Nu-Tiny-EVB and Nu-Link-Me Board user manual EN v1.0.pdf”文档
 NUC1xxNuTinyEVBandNuLinkMeBoardusermanualENv10.pdf
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Documents/NUC1xxNuTinyEVBandNuLinkMeBoardusermanualENv10.pdf

 下载“NUC1xx Nu-Link-Me_001 Board Schematic v1.0.pdf”文档
 NUC1xxNuLinkMe_001BoardSchematicv10.pdf
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Documents/NUC1xxNuLinkMe_001BoardSchematicv10.pdf

 下载“NUC1xx Nu-Tiny-EVB_001 Board Schemetic v1.0.pdf”文档
 NUC1xxNuTinyEVB_001BoardSchemeticv10.pdf
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Documents/NUC1xxNuTinyEVB_001BoardSchemeticv10.pdf
 
3,在https://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=7052964b-b71b-46b7-91b2-221afeddd575
 上下载 “NUC1xxBSP_v1.1.1.zip”
 NUC1xxBSP_v111.zip
 https://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=38a57efd-e9f8-4809-a585-21e62f8b6041

4,新唐官方资料网址
 新唐CM0官方资料主页
 https://www.nuvoton.com/hq/chs/Pages/default.aspx
 新唐CM0主页资料入口
 ARM单片机 -> ARM Cortex?-M0 单片机 NuMicro? 家族
 新唐CM0主页资料网址
 https://www.nuvoton.com/NuvotonMOSS/Community/ProductInfo.aspx?tp_GUID=30cfcae5-0f93-414d-a8df-b3bac8b932a2
 新唐CM0在线选型工具
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Pages/SelectGuide.aspx
 新唐CM0在线培训教程
 https://www.nuvoton.com/hq/enu/ProductAndSales/ProductLines/ConsumerElectronicsIC/ARMMicrocontroller/ARMCortexTMM0/Pages/OnLineTraining.aspx

二,建立CM0的MDK-ARM+Nu-LINK开发环境

1,双击“mdk412_mcu123.rar”运行里面的“MDK412.exe”,一路的“NEXT”再“NEXT”,最后就会安装MDK-ARM 4.12到电脑上,将会在桌面产生Keil uVision4的快捷方式;

2,双击“keygen.exe”,把“uVision4”的“File->License Management”菜单里面的“CID”复制到keygen里面的CID框中,选择“TARGET”为“ARM”后点击“Generate”,把
 产生的序列号复制到前面“uVision4”的窗口中的“LIC”框中,点击“ADD LIC”便会解除编译限制;

3,双击“NUC1xxKeilICEdriverBuild3814V101.zip ”运行里面的“Nu-Link_Driver.EXE”,便会在KEIL目录中安装上相关的“Nu-LINK”的驱动。

三,建立CM0的MDK-ARM基本工程

1,在电脑开始菜单中打开“Keil uVision4”,在“uVision4”的IDE菜单中选择“Project”->“New uVision Project”创建一个新工程,在“Create New Project”选择存储目录
 到D:\works\9G-CM0\nuc140\project下面,工程名叫“nuc140.uvproj”;

2,接着在“select a CPU Data Base File”菜单中选择“NUVOTON NUC1XX Devices”点击“OK”,选择“Nuvoton”公司下面的“NUC140VE3AN”点击“OK”后确认复制启动代码“startup_NUC1xx.s”和
 加入到工程项目中,即可产生一个空工程,再点击全部保存项目,会D:\works\9G-CM0\nuc140\project目录中发现“nuc140.uvproj”和“nuc140.uvopt”,“startup_NUC1xx.s”等文件;

3,在“D:\works\9G-CM0\nuc140”下建立文件夹“include”,“driver”,“library”,“source”,等子目录,解压“NUC1xxBSP_v111.zip”,把里面的目录“NUC1xxBSP”解压到“library”里面,在D:\works\9G-CM0\nuc140\project
 下建立子目录“obj”和“lst”;

4,在“uVision4”的IDE菜单中选择“Project”->“Manage”->“Components,Environment,Books”打开“Components,Environment,Books”页面里的“Project Components”,
 双击“Target1”改名为“NUC140”,双击“Source Group 1”改名为“boot”再添加“lib”“drv”“src”“inc”等目录后确定。

5,在“uVision4”的IDE菜单中选择“File”->“New”后选择“File”->“Save”把新建立的文件保存到D:\works\9G-CM0\nuc140\source,文件名为“main.c”,右击项目窗口中的“src”选择“Add Files
 to Group 'src'”并在“main.c”中填入下面内容:
  #include <NUC1xx.H>                            /* NUC1xx definitions                 */
  void SystemInit(void){}
  void GPIO_Init(void){ NUC_GPIOC->PMD   = 0x00005555;}     /* LEDs on PORT C defined as Output   */
  int main(void)
  {
   int i;
  
   GPIO_Init();
   while(1)
   {
    for(i=0;i<1000000;i++);  NUC_GPIOC->DOUT &= 0xFFFFFF00; /* switch on LEDs                    */
    for(i=0;i<1000000;i++);  NUC_GPIOC->DOUT |= 0x000000FF; /* switch off LEDs                    */
   }
  }
  
三,配置CM0的MDK-ARM基本工程

1,在“uVision4”的IDE菜单中选择“Project”->“Opitions for Target ‘NUC140’”,在“Output”页面勾选“Create HEX File”,并在“Select Folder Objects”指定目录到“D:\works\9G-CM0\nuc140\project\obj”,
 后点击“OK”,同样在“Listing”中在“Select Folder Listings”指定目录到“D:\works\9G-CM0\nuc140\project\lst”;

2,在“Opitions for Target ‘NUC140’”的“Debug”页面选择用硬件仿真器“Nu-Link Debugger”勾选“Run to main{}”,在“Utilities”页面选择“Use Target Driver for Flash Programming”用
 “Nu-Link Debugger”勾选上“Update Target before Debugging”后在“Setting”里面的“Configure”,确保用内置22M晶体,和从“APROM”启动及低压检测电压值等配置选项后点击“OK”再“OK”退出;
 
3,在“Opitions for Target ‘NUC140’”的“C/C++”页面的“Include Paths”中填入“C:\Keil\ARM\INC\Nuvoton\NUC1xx”

四,调试CM0的MDK-ARM基本工程

1,点击在“uVision4”的IDE菜单中选择“Flash”->“Download”便会自己编译代码生成HEX文件并下载到目标板子中;

2,点击在“uVision4”的IDE菜单中选择“Debug”->“Start/Stop Debug session”进入调试状态,然后选择“Debug”->“Run”,全速运行,可以看到IO口上的LED在闪烁。9G-CM0-20100629.zip

四,建立CM0的MDK-ARM高级工程
(待续)