【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