本帖最后由 hotpower 于 2012-9-13 22:59 编辑
9G-MINI51 新唐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=2&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
下载?M051软件库资源“M051SeriesBSP_CMSIS V1.02.001”和“M051SeriesBSP_RegCtrlPrg V1.00.002”
M051SeriesBSP_v1.02.001.zip
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=NDV8ZTc3MTg5M2V8MTMxNTM3NjExOHww
M051SeriesBSP_RegCtrlPrg.zip
http://www.nuvoton-m0.com/forum.php?mod=attachment&aid=NDZ8OTVlMjM1OGN8MTMxNTM3NjExOHww
3,在“http://dzstic.com/down.asp”上下载“NuTiny-EVB-Mini51_V002”文档
NuTiny-EVB-Mini51_V002.rar
http://dzstic.com/upload/20110907/20110907141832652.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-MINI51\prj”下面,工程名叫“MINI51.ewp,点击“OK”完成,点击“File”下的“Save Workspace”保存工作空间到目录中的“MINI51.eww”;
2,在“D:\works\9G-CM0\9G-MINI51”下建立文件夹“bsp”“drv”“inc”“src”,等子目录,在“D:\works\9G-CM0\9G-MINI51\prj”下建立子目录“config”,并把 “M051SeriesBSP_v1.02.001.zip”
的“M051SeriesBSP\NuvotonPlatform_IAR\Src\Driver”和“M051SeriesBSP\NuvotonPlatform_IAR\Include\Driver”解压到“D:\works\9G-CM0\9G-MINI51\bsp\Driver”目录,把“M051SeriesBSP\
NuvotonPlatform_IAR\Include\System”解压到“D:\works\9G-CM0\9G-MINI51\bsp\System”目录,把“M051SeriesBSP\CMSIS\CM0\DeviceSupport\Nuvoton\M051Series\startup\iar\startup_M051Series.s”解压到
“D:\works\9G-CM0\9G-MINI51\bsp\Boot”,把“M051SeriesBSP\CMSIS\CM0\DeviceSupport\Nuvoton\M051Series”下的H和C文件及“M051SeriesBSP\CMSIS\CM0\CoreSupport”下的H和C文件解压到
“D:\works\9G-CM0\9G-MINI51\bsp\Cmsis”;
3,在“EWARM”的IDE菜单中选择“Project”->“Options”中的“General Options”的“Target”中的“Device”中选择“Nuvoton Mini51 series (Mini51,Mini52,Mini54)”,在“Linker”菜单中选择“Linker configuration file”里选择
“override default”并填上“$PROJ_DIR$\config\M052_Flash.icf”,在“Library Configuration”下的库选项用“FULL”在“Library Opitions”下的“printf”和“scanf”格式也用“FULL”;
4,在“Options for node 'MINI51'”的“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\Mini51_APROM.board”,把
“C:\Program Files\Nuvoton Tools\Nu-Link_IAR\Samples\M052\config”下的“M052_Flash.icf”复制到“D:\works\9G-CM0\9G-MINI51\prj\config”,
把“C:\Program Files\Nuvoton Tools\Nu-Link_IAR\Samples\M052”下的“SH_retarget.c”和“SH_startup_M05x_iar.s”复制到“D:\works\9G-CM0\9G-MINI51\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-MINI51\bsp\Boot”下的“SH_retarget.c”,“SH_startup_NUCxxx_iar.s”和“D:\works\9G-CM0\9G-MINI51\bsp\Cmsis”下的
“core_cm0.c”和“system_M051Series.c”;同样用“Add”->“Add Files”把“D:\works\9G-CM0\9G-MINI51\bsp\Driver”的文件添加到“bsp”目录;(retarget.c除外)
7,在“D:\works\9G-CM0\9G-MINI51\src”中建立“main.c”,然后添加到工程的“src”中,并在“main.c”中填入下面内容:
#include <stdio.h>
#include <stdint.h>
#include <Nuvoton\iom05x.h>
int main(void)
{
uint32_t i=0;
/* Output a message on Hyperterminal using printf function */
printf("\n\r\n\r");
printf("*** 9G-MINI51 V1.00 Build by yuanxihua@21cn.com on ("__DATE__ " - " __TIME__ ")\n\r");
printf("*** 9G-MINI51 V1.00 Rebooting ...\n\r\n\r");
while(1)
{
for(uint32_t j = 0; j <800000; j++);
GPIO_P0_DOUT = 0x5E; /* switch on LEDs */
GPIO_P1_DOUT = 0xCA;
GPIO_P2_DOUT = 0xAB;
GPIO_P3_DOUT = 0x9A;
GPIO_P4_DOUT = 0xE2;
for(uint32_t j = 0; j <800000; j++);
GPIO_P0_DOUT = 0xAD; /* switch off LEDs */
GPIO_P1_DOUT = 0xF7;
GPIO_P2_DOUT = 0xD7;
GPIO_P3_DOUT = 0xED;
GPIO_P4_DOUT = 0xDD;
printf("*** 9G-MINI51 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即可。) 缥缈九哥测试记录程序:
9G-MINI51.rar
(114.68 KB)
。 |