锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

MSP430开发环境MSPGCC + Codeblocks

时间:2024-05-02 08:37:09

我比较喜欢简单小巧的东西,所以官方的不太适合我,IAR又要破解,所以选择这个平台作为MSP430的开发环境。
codeblocks本身就集成MSPC编译器的模板,但是新版的MSPGCC比起旧版的似乎有点不一样,所以需要做一些配置的工作。
理论上,搭建方法也适用于linux系统,我个人还没在linux下搭建。

相比Eclipse,codeblocks显得很小巧(不想要MinGW的话也不到30M),无需JAVA环境,运行速度也很快,支持搭建多种开发环境,是我摆弄东西的首选平台。至于它的其它优点,自行google吧。

我的mspgcc是放在D:\mspgcc目录下,TI官方的烧录软件我放在"D:\mspgcc\flash_fet"目录下 ,请读者自行修改。
开始:
1) 先安装好codeblocks 10.05,这个很简单。下面的一个是不带minGW的只有23M,带minGW的74M
http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05-setup.exe/download
http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download
2)下载MSPGCC(新版的只有37M),解压到“D:\mspgcc”
http://sourceforge.net/projects/mspgcc/files/Windows/mingw32/mspgcc-20120406-p20120502.zip/download
3)下载TI LuanchPad软件包,并将里面Flasher,driver等解压到“D:\mspgcc”目录下。(附件)

4)运行codeblocks,点击Setting->Compiler and debugger..
选择编译器 “GNU GCC Compiler for MSP430”


注意:如果你只用到一种编译设置只用一种型号的的话,Complier Flags的话可以也可以在这里设置。(我个人不推荐~~)

切换到"Toolchain executables",修改如下


本页下切换到“Addition Paths”,将msp430的目录也加上


切换到"Search directories", 添加Compiler的include目录和linker的lib目录





保存。


5)新建一个项目。File->New->project->Empty project
一般我都只勾选Release,不要Debug






7)新建空白文件,并添加到项目中File->New->Empty file
输入测试代码。我的LaunchPad代码(没注释的,见笑了):
#include

void delay(int duration)
{
volatile int d = duration;
while((d--) > 0)
{
}
}

int main(void)
{
WDTCTL = WDTPW | WDTHOLD;

P1OUT = 0x00;
P1D = 0x41;

while(1)
{
P1OUT = 0x40;
delay(5000);
P1OUT = 0x01;
delay(5000);
}
return 0;
}
提醒一下:delay函数里面的变量要加上volatile修饰。

8)在编译之前还有一些重要的工作要做。
Project->Propertise..->Build targets



以下内容也可以在上面红色字体的页面设置(不推荐)
9)Project->Build Options..








我的设置:
msp430-objcopy -O ihex bin/Release/CB_MSP430_test001.elfbin/Release/CB_MSP430_test001.a43
D:/mspgcc/msp_fet/MSP430Flasher.exe -n msp4302553 -w bin/Release/CB_MSP430_test001.a43 -v -g -z []


至此,设置完成。

可以点击运行了。成功后显示信息~~

-------------- Build: Release in CB_MSP430_test001 ---------------

msp430-gcc.exe -Wall -mmcu=msp430g2553-Os -O3 -ID:\mspgcc\msp430\include -ID:\mspgcc\include-c CB_MSP430_test001.c -o obj\Release\CB_MSP430_test001.o
msp430-gcc.exe -LD:\mspgcc\msp430\lib\ldscripts\msp430g2553 -LD:\mspgcc\msp430\lib -LD:\mspgcc\lib-o bin\Release\CB_MSP430_test001.elf obj\Release\CB_MSP430_test001.o -s
Output size is 584.00 bytes
Running target post-build steps
msp430-objcopy -O ihex bin/Release/CB_MSP430_test001.elfbin/Release/CB_MSP430_test001.a43
D:/mspgcc/msp_fet/MSP430Flasher.exe -n msp4302553 -w bin/Release/CB_MSP430_test001.a43 -v -g -z [VCC]
**ERROR: Unable to access log file. Log disabled.
**Please make sure the directory 'Log' exists in line with the executable.
Evaluating additional triggers...done
Initializing interface on TIUSB port...done
Checking firmware compatibility...done
Reading FW version...done
Reading HW version...done
ing up...done
Configuring...done
Accessing device...done
Reading device information...done
Loading file into device...done
Verifying transfer...done
Resetting device...done
Refreshing registers...
/* ----------------------------------------------------------------------------
* UseCase : MSP430Flasher.exe
* Arguments : -n MSP4302553 -w bin/Release/CB_MSP430_test001.a43 -v -g -z [VCC]
* TION: Default options used due to invalid argument list.
* ----------------------------------------------------------------------------
* Driver : loaded
* Dll Version : 20409001
* FwVersion : 30394216
* Interface : TIUSB
* HwVersion : E 2.0
* Mode : AUTO
* : MSP430G2xx3
* EEM : Level 1, ClockCntrl 1
* Prog.File : bin/Release/CB_MSP430_test001.a43 (ERASE_ALL, verified = TRUE)
* BSL Unlock: FALSE
* InfoA Access: FALSE
* VCC ON : TRUE
* UseCase specific tasks: ----------------------------------------------------
* Powering up...done
* Disconnecting from device...
* ----------------------------------------------------------------------------
* Driver : closed (No error)
* ----------------------------------------------------------------------------
*/
Process terminated with status 0 (0 minutes, 7 seconds)
0 errors, 0 warnings

LaunchPad下载:http://www.51hei.com/f/TI_LaunchPad.zip


-电子元器件采购网(www.ruidan.com)是本土元器件目录分销商,采用“小批量、现货、样品”销售模式,致力于满足客户多型号、高质量、快速交付的采购需求。 自建高效智能仓储,拥有自营库存超过50,000种,提供一站式正品现货采购、个性化解决方案、选型替代等多元化服务。
锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章