3434|2

6366

帖子

4912

TA的资源

版主

楼主
 

如何用GCC开发MSP430 Launchpad(英文) [复制链接]

How to develop MSP430 Launchpad code on LinuxPDFPrintE-mail

The LaunchPad is an easy-to-use, affordable, and scalable introduction to the world of microcontrollers and the MSP430 family.

The LaunchPad development kit is a part of TI's MSP430 Value Line series. It has an integrated DIP target socket that supports up to 20 pins, allowing MSP430 Value Line devices to be dropped into the LaunchPad board. Also, an on-board flash emulation tool allows direct interface to a PC for easy programming, debugging, and evaluation.

Unfortunately, the TI supported tools for this kit are Windows only.

It is, however, quite possible to use Linux based tools with Launchpad.  The procedure below outlines the steps to build a Linux based tool chain and debugger, as well as create and test a short C program.

The procedure below should work on either your x86 Linux machine or on an OMAP system using the GNOME image from this site.

If you are using the GNOME image from this site all necessary packages to build the msp430 tools are included.  If you are using an x86 machine you may need to install a few required packages (the below assumes you are using Ubuntu, modify as needed for your distro):

$ sudo aptitude install git-core gcc-4.4 texinfo patch libncurses5-dev
$ sudo aptitude install zlibc zlib1g-dev libx11-dev libusb-dev libreadline6-dev

Next we will download and build the mspgcc compiler:

git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4
cd mspgcc4
sudo sh buildgcc.sh

The build script will ask a number of questions.  Accept the default by pressing Enter for each question except "Do you want to start build right now?"  The proper response here is of course "yes"!

Next we download and build mspdebug:

cd ..
git clone git://mspdebug.git.sourceforge.net/gitroot/mspdebug/mspdebug
cd mspdebug
make
sudo make install

At this point we're ready to test our first MSP430 program: blinking the red LED connected to the P1 pin.

Create a blink.c file using your favorite editor:

/* Demo app to blink the red LED on the TI Launchpad */

#include <msp430g2231.h>

int main(void) {
volatile int i;

// stop watchdog timer
WDTCTL = WDTPW | WDTHOLD;
// set up bit 0 of P1 as output
P1DIR = 0x01;
// intialize bit 0 of P1 to 0
P1OUT = 0x00;

// loop forever
for (;;) {
// toggle bit 0 of P1
P1OUT ^= 0x01;
// delay for a while
for (i = 0; i < 0x6000; i++);
}
}

Next compile your program:

$ /opt/msp430-gcc-4.4.5/bin/msp430-gcc -oS -o blink.elf blink.c

Connect the Launchpad to your development machine using the supplied USB cable.  Use MSPDebug to download and launch your program.

$ sudo mspdebug rf2500
(mspdebug) prog blink.elf
Erasing...
Programming...
Writing 104 bytes to fc00...
Writing 32 bytes to ffe0...
(mspdebug) run
Running. Press Ctrl+C to interrupt...

You should now see the red LED blinking!

Tags: MSP430 How to
Last Updated on Friday, 27 May 2011 08:21

最新回复

GCC如果可以 那就方便多了 支持马哥  详情 回复 发表于 2012-6-11 17:09
 
点赞 关注

回复
举报

6366

帖子

4912

TA的资源

版主

沙发
 
7 Comments

gordon         makes this comment
Monday, 23 May 2011
The code above will not blink the LED, because the empty loop will be optimized away by the compiler. Without that wait, the result is a constantly lit LED, which is a bit less bright than what you would expect.

You need to declare i as being volatile for it to work as expected, so change
int i;

to
volatile int i;

to have the desired effect.
sakoman         makes this comment
Monday, 23 May 2011
Quote:
You need to declare i as being volatile for it to work as expected


Good point -- wasn't necessary when I ran the test. I suspect compiler quality has improved since I built it!

I've fixed the code in the article. Thanks!
arvindh         makes this comment
Tuesday, 06 September 2011
hi,

i get an error while compiling,.. saying as
bash: /opt/msp430-gcc-4.4.5/bin/msp430-gcc: No such file or directory

when i moved to /opt/msp430-gcc-4.4.5 directory i found it completely empty,.
please can anybody help me
sakoman         makes this comment
Friday, 09 September 2011
Quote:
i get an error while compiling,.. saying as
bash: /opt/msp430-gcc-4.4.5/bin/msp430-gcc: No such file or directory


I suspect that you had an error and the compiler build failed. Try again to build the compiler and post any error messages.
Joao Pinto         makes this comment
Monday, 14 November 2011
When I try to run the install script I get the following error:

(...)
-------------------------------------
Do you want to start build right now? (y/n) [n] y
Running sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build"
--2011-11-14 13:48:29-- http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.21.tar.bz2
Resolving ftp.uni-kl.de... 131.246.123.4, 2001:638:208:ef1b:0:ff:fe00:4
Connecting to ftp.uni-kl.de|131.246.123.4|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2011-11-14 13:48:30 ERROR 404: Not Found.

sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build" exited with status code 8.
Failed to execute sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build" at ./buildgcc.pl line 248, line 9.

How can solve this? Has anyone found the same error?
Khaine         makes this comment
Wednesday, 23 November 2011
I found the same error as Joao Pinto. Apparently the repository doesn't exist anymore. Anyone got some alternate location?
TecKnight         makes this comment
Tuesday, 31 January 2012
In buildgcc.pl
Change the line:
$BINUTILS_VERSION = "2.21";
to
$BINUTILS_VERSION = "2.22";
Add Comment
 
 

回复

7219

帖子

195

TA的资源

五彩晶圆(高级)

板凳
 
GCC如果可以 那就方便多了 支持马哥
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表