9G-NUC140 新唐CM0+EWARM入门开发过程简介
一,准备EWARM + 新唐CM0软件包
1,在http://www.mcu123.com/news/Soft/ShowSoftDown.asp?UrlID=1&SoftID=535 上
下载 IAR Embedded Workbench for ARM v6.20 FULL CD-EWARM-6201-2590 软件
CD-EWARM-6201-2590_mcu123.zip
ftp://mcu123:mcu123@mcu123.com/已整理目录/开发工具软件/ARM/CD-EWARM-6201-2590_mcu123.zip
相关文件“IAR_EWARM5.4和谐文件.rar ”可以在GOOGLE上搜索到
http://bbs.mcu123.net/bbs/thread-15164-1-1.html
并下载:
IAR_EWARM5[1].4和谐文件.rar
2,在http://www.nuvoton-m0.com/forum.php?mod=viewthread&tid=1&extra=page%3D1上
下载Nu-Link驱动“公测版驱动下载 v1.17.5218,支持最新的IAR 6.21”
Nu-Link_IAR_Driver 1.17.5218.zip
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=MTg3fDI4NGFkNTk1fDEzMTUyOTkyOTF8MA%3D%3D
下载ICP编程工具“NuMicro ICP Programming Tool 1.17.5218”
NuMicro ICP Programming Tool 1.17.5218.zip
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=MTg2fDI3YTFmZmJlfDEzMTUyOTkyOTF8MA%3D%3D
下载ISP编程工具“NuMicro ISP Programming Tool v1.41”
NuMicro ISP Programming Tool V1.41.zip
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=NDh8OTBkZjBjYTJ8MTMxNTI5OTI5MXww
下载NUC100系列基础程序库“NUC100Series BSP_CMSIS V1.05.001.7z”
NUC100SeriesBSP_v1.05.001.7z
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=NTR8YWY2YWI1Njd8MTMxNTMwMDA0OHww
3,在“http://dzstic.com/down.asp”上下载“NuTiny-SDK-NUC140.rar”文档
NuTiny-SDK-NUC140.rar
http://dzstic.com/upload/20110906/20110906162939454.rar
4,新唐官方资料网址
新唐CM0官方资料主页
http://www.nuvoton.com/hq/chs/Pages/default.aspx
二,建立CM0的EWARM+Nu-LINK开发环境
1,双击“IAR_EWARM5[1].4和谐文件.rar”,运行里面的“EWARM_FULL_ARM540.exe”,选择“Product”中的“Embedded Workbench For ARM v5.40”,然后点击“Generate”
把产生的“License key”“License number”密码和序列号记录下来;
2,双击“CD-EWARM-6201-2590_mcu123.zip”运行里面的“autorun.exe”,在“IAR Embedded Workbench For ARM”中选择“Install IAR Embedded Workbench”,按常规的软件安装方式
把“IAR Embedded Workbench For ARM”安装到电脑上;
3,双击“Nu-Link_IAR_Driver 1.17.5218.zip”运行里面的“Nu-Link_IAR_Driver 1.17.5218.exe”,便会在“C:\Program Files\Nuvoton Tools\Nu-Link_IAR”和“C:\Program Files
\IAR Systems\Embedded Workbench 6.0” 目录中安装上相关的“Nu-LINK”的驱动。
4,双击“NuMicro ICP Programming Tool 1.17.5218.zip”运行里面的“NuMicro ICP Programming Tool 1.17.5218.exe”,便会在“C:\Program Files\Nuvoton Tools\ICPTool”
目录中安装上相关的“ ICP Programming Tool”的工具。
三,建立CM0的EWARM基本工程
1,在电脑开始菜单中打开“IAR Embedded Workbench IDE”,在“EWARM”的IDE菜单中选择“Project”->“Create New Project”创建一个新工程,在“Create New Project”选择“OK”存储目录
到“D:\works\9G-CM0\9G-NUC140\prj”下面,工程名叫“nuc140.ewp”,点击“OK”完成,点击“File”下的“Save Workspace”保存工作空间到目录中的“nuc140.eww”;
2,在“D:\works\9G-CM0\nuc140”下建立文件夹“bsp”“drv”“inc”“src”,等子目录,在“D:\works\9G-CM0\9G-NUC140\prj”下建立子目录“config”,并把 “NUC100SeriesBSP_v1.05.001.7z”
的“NUC100SeriesBSP\NuvotonPlatform_IAR\Src\Driver”和“NUC100SeriesBSP\NuvotonPlatform_IAR\Include\Driver”解压到“D:\works\9G-CM0\9G-NUC140\bsp\Driver”目录,把“NUC100SeriesBSP\
NuvotonPlatform_IAR\Include\System”解压到“D:\works\9G-CM0\9G-NUC140\bsp\System”目录,把“NUC100SeriesBSP\CMSIS\CM0\DeviceSupport\Nuvoton\NUC1xx\startup\iar\startup_NUC1xx.s”解压到
“D:\works\9G-CM0\9G-NUC140\bsp\Boot”,把“NUC100SeriesBSP\CMSIS\CM0\DeviceSupport\Nuvoton\NUC1xx”下的H和C文件及“NUC100SeriesBSP\CMSIS\CM0\CoreSupport”下的H和C文件解压到
“D:\works\9G-CM0\9G-NUC140\bsp\Cmsis”;
3,在“EWARM”的IDE菜单中选择“Project”->“Options”中的“General Options”的“Target”中的“Device”中选择“Nuvoton NUC140xE”,在“Linker”菜单中选择“Linker configuration file”里选择
“override default”并填上“$PROJ_DIR$\config\NUC140_Flash.icf,在“Library Configuration”下的库选项用“FULL”在“Library Opitions”下的“printf”和“scanf”格式也用“FULL”;
4,在“Options for node 'nuc140'”的“Category:”中选择上“Debugger”,在“Setup”->“Driver”中选择“Third-Party Driver”,然后在“Third-Party Driver”选择驱动到
“C:\Program Files\Nuvoton Tools\Nu-Link_IAR\Nu-Link_IAR.dll”,在“C/C++ Compiler”下的“Preprocessor”下面的方框内填上:
$PROJ_DIR$\..\inc\
$PROJ_DIR$\..\bsp\
$PROJ_DIR$\..\bsp\Cmsis\
$PROJ_DIR$\..\bsp\Driver\
5,在“Debugger”的“Download”勾选择“Use flash loader”和“override default .board file”并填入“$TOOLKIT_DIR$\config\flashloader\Nuvoton\NUC100_APROM.board”,把
“C:\Program Files\Nuvoton Tools\Nu-Link_IAR\Samples\NUC140_PWM\config”下的“NUC140_Flash.icf”和“NUC140_Ram.icf”复制到“D:\works\9G-CM0\9G-NUC140\prj\config”,
把“C:\Program Files\Nuvoton Tools\Nu-Link_IAR\Samples\NUC140_PWM”下的“SH_retarget.c”和“SH_startup_NUCxxx_iar.s”复制到“D:\works\9G-CM0\9G-NUC140\bsp\Boot”;
6,在“IAR Embedded Workbench IDE”的“Workspace”下的“Files”中右击选择“Add”->“Add Group”并填入“sys”,另外同样建立“bsp”,“drv”,“src”等目录,然后在“sys”上右击
选择“Add”->“Add Files” 然后选择“D:\works\9G-CM0\9G-NUC140\bsp\Boot”下的“SH_retarget.c”,“SH_startup_NUCxxx_iar.s”和“D:\works\9G-CM0\9G-NUC140\bsp\Cmsis”下的
“core_cm0.c”和“system_NUC1xx.c”;同样用“Add”->“Add Files”把“D:\works\9G-CM0\9G-NUC140\bsp\Driver”的文件添加到“bsp”目录;(retarget.c和DrvUSB.c除外)
7,在“D:\works\9G-CM0\9G-NUC140\src”中建立“main.c”,然后添加到工程的“src”中,并在“main.c”中填入下面内容:
#include <stdio.h>
#include <stdint.h>
#include <Nuvoton\ionuc1xx.h>
int main(void)
{
uint32_t i=0;
/* Output a message on Hyperterminal using printf function */
printf("\n\r\n\r\n\r\n\r");
printf("*** 9G-NUC120 V1.00 Build by yuanxihua@21cn.com on ("__DATE__ " - " __TIME__ ")\n\r");
printf("*** 9G-NUC120 V1.00 Rebooting ...\n\r\n\r");
while(1)
{
GPA_DOUT =0xffff;
for(uint32_t j = 0; j <1000000; j++);
GPA_DOUT =0x0000;
for(uint32_t j = 0; j <1000000; j++);
printf("*** 9G-NUC140 V1.00 Running %d Times...\n\r",i++);
}
}
(编译时会有与core_cm0.h与“C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\inc\c\intrinsics.h”相冲突时,
把有问题的uint32_t改回相应的 unsigned long即可;)
8,在“Debugger”的“Download”勾选择“Use flash loader”和“override default .board file”并填入“$TOOLKIT_DIR$\config\flashloader\Nuvoton\NUC100_LDROM.board”,可以把
相应的程序烧进LDROM区;
9,在“EWARM”的IDE菜单中选择“Nu-Link”->“ICP Programming Tool”中,可以不擦除整片FLASH直接改变配置位从APPROM区切换到LDROM区启动,FLASH的1能修改成0;
离线