【test.c】
#include <io.h>
// LED灯是接到P5.4~P5.6上的
void wait(void)
{
volatile unsigned int i; // volatile不可省略
for (i = 0; i < 32000; i++);
}
int main(void)
{
P5DIR = 0xff;
P5OUT = 0x00;
while (1)
{
P5OUT ^= 0x70;
wait();
}
}
【Makefile】
# ubuntu系统下执行make run即可编译并烧写
# 注意确保ttyUSB0的权限
test: test.c
msp430-gcc -Os -mmcu=msp430x1611 -g -o test.elf test.c
msp430-objcopy -O ihex test.elf test.hex
run: test
tos-bsl --telosb -r -e -I -c /dev/ttyUSB0 -p test.hex
# 输入命令时,一定要注意区分大写i和小写L