多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
* 导师视频讲解:[**去听课**](https://www.bilibili.com/video/BV1k34y1D7Vz?p=3) >[success] **技术支持说明:** >**1**.一般以自主学习为主 > **2**.可到官方问答社区中提问:[**去提问**](https://bbs.csdn.net/forums/zigbee) > **3**.工程师**会尽快**解答社区问题,但他们是一线开发,【**难以保证**】解答时效,解答辛苦,感谢理解! <br/> ## **新建源码文件夹** 在保存工作空间和工程的目录下,新建一个code文件夹,用于保存源码,如图所示。 ![](https://img.kancloud.cn/a6/37/a637857a35da07eec6039d937d32fee9_315x263.png =200x) ### 依次选择File和New File,新建源代码文件,如图所示。 ![](https://img.kancloud.cn/0b/d6/0bd6de79c35629eb537f0821876d558e_419x706.png =300x) ### 新建源代码文件成功,如图所示。 ![](https://img.kancloud.cn/a9/eb/a9ebec2e6182f7a171a98e7cf6e9373d_1110x704.png =600x) ### 点击Save按钮,保存源文件,如图所示。 ![](https://img.kancloud.cn/1e/8a/1e8adfeba9d4a49efa62c2ec9f8fa77e_415x463.png =300x) ### 选择源文件保存目标,并把源文件命名为main.c,然后点击保存,如图所示。 ![](https://img.kancloud.cn/d5/64/d564201b8341010d1112791f0f692418_944x595.png =400x) <br/> ## **添加源文件到工程中** 鼠标右击工程名称,然后依次选择Add和AddGroup,新建一个组,如图所示。 ![](https://img.kancloud.cn/5b/68/5b68557bb4386fbdcc3e1195f11e6fc4_600x709.png =400x) ### 设置组名称为Main,然后点击OK,如图所示。 ![](https://img.kancloud.cn/03/db/03db82868b7cc3502b7ff0a424af2988_387x148.png =300x) ### 鼠标右击新建的组,依次选择Add和Add "main.c",在组中添加新建的源文件,如图所示。 ![](https://img.kancloud.cn/84/14/8414cab06d3c34a17334717dd86d52be_618x708.png =400x) ### 添加源文件成功后,如图所示。 ![](https://img.kancloud.cn/46/6d/466d8229a0e7a80dad6fba4f01763be3_415x464.png =350x) <br/> ## **编写一个简单的测试程序** 添加好main.c后,可以在mian.c添加如下代码: ``` #include "ioCC2530.h" #include <stdio.h> void main() { printf("Hello World!\r\n"); while(1){}//无限循环 } ``` <br/> ## **设置字体和行号** 可以根据个人喜好来设置代码字体和行号,依次选择Tools和Options,打开设置,如下图所示。 ![](https://img.kancloud.cn/19/7f/197fdd9ee5e68e08b9b802af805a6dd1_620x328.png =400x) ### 依次选择Editor、Colors and Font,然后点击Font...,最后选择字体,如图所示。 ![](https://img.kancloud.cn/79/4a/794a7b54cccc526e6159060d92da649e_974x663.png =600x) ### 选择Editor,然后勾选Show line numbers,显示行号,如图所示。 ![](https://img.kancloud.cn/0f/05/0f059b54247064fdb1b759f503901cb3_975x660.png =600x) <br/> ## **工程配置** 添加好源代码后,需要配置一下工程后才能编译。鼠标右击工程名称,然后选择Options...,如图所示。 ![](https://img.kancloud.cn/62/65/626508c3f2421723c4e5b30ac49ba0e3_701x516.png =400x) <br/> **基础配置** 可以根据所使用的ZigBee芯片型号来进行配置,这里以CC2530F256为例讲解配置过程。依次选择General Options、Target、Device和Texas Instruments,如图所示。 ![](https://img.kancloud.cn/30/41/304116e865ac396c7f77736bd5d16341_967x948.png =500x) ### 依次选择CC25xx、3x和CC2530F256,如图所示。 ![](https://img.kancloud.cn/d0/f3/d0f3e169163cb0a1f279e7c079dab1fa_787x267.png =300x) ### 确认配置没有问题后,点击OK,如图所示。 ![](https://img.kancloud.cn/93/1a/931aded1839ec8b7f7029151bec770e4_811x668.png =600x) ### 选择Stack/Heap,配置数据段XDATA的大小为1FF,如图所示。 ![](https://img.kancloud.cn/15/87/1587121f27477b684856cf54004f2f1c_808x668.png =600x) <br/> **链接和输出配置** 依次选择Linker和Config,然后选lnk51ew_cc2530f256_banked.xcl,如图所示。 ![](https://img.kancloud.cn/ab/3e/ab3e8fd6a7a60338a8a6fdf583683567_826x675.png =600x) ### 选择Output,按如图所示配置。 ![](https://img.kancloud.cn/95/10/95107a2b9b096e24a249f68e0848aeff_826x675.png =600x) ### 选择Extra Output,按如图所示配置。 ![](https://img.kancloud.cn/50/6e/506ee3830fa52b291379df939fe18fa7_813x670.png =600x) ### 选择Debugger,在Driver中选择Texas Instruments,如图所示。 ![](https://img.kancloud.cn/fa/54/fa5432015d2910985d79856ae84ff9c1_850x670.png =600x) <br/> ## **编译链接工程** 配置完成后,可以编译链接工程。鼠标右击工程名字,然后选择Rebuild All,重新编译链接整个工程,如图所示。 ![](https://img.kancloud.cn/ae/4f/ae4f863703b8e7183bf7d4fc6bee38f0_773x597.png =500x) ### 可以在如图所示位置查看编译链接结果。 ![](https://img.kancloud.cn/29/33/29334791d4afea4bded6e64072134f75_777x1029.png =500x) <br/> <br/> ## **商务合作** 如有以下需求,可扫码添加管理员好友,注明“**商务合作**” * 项目定制开发,技术范围:**NB-IoT**、**CATn(4G)**、**WiFi**、**ZigBee**、**BLE Mesh**以及**STM32**、**嵌入式Linux**等; * 入驻平台,成为讲师; * 接项目赚外快; * 善学坊官网:[www.sxf-iot.com](https://www.sxf-iot.com/) ![](https://img.kancloud.cn/ca/73/ca739f92cab220a3059378642e3bd502_430x430.png =200x) * 非合作**勿扰**,此处**非**技术支持