тут есть пример кода
http://electronix.ru/forum/index.php?showt...42599&st=15/////// main.c //////////////////////////////////////////////////////////////////////////////
#include "io.h"
#include "signal.h"
int main(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 &= ~XT2OFF; // XT2on
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG) != 0); // OSCFault flag still set?
BCSCTL2 |= SELM1+SELS; // MCLK = SMCLK = XT2
UCTL1 = CHAR; // 8-bit character
UTCTL1 = SSEL1; // UCLK = SMCLK
UBR01 = 0x80; // 8Mhz/115200 - 69.44
UBR11 = 0x01; //
UMCTL1 = 0x2C; // modulation
ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD
IE2 |= URXIE1; // Enable USART1 RX interrupt
P3SEL |= 0xC0; // P3.6,7 = USART1 option select
P3DIR |= 0x20; // P3.6 = output direction
_EINT(); // Enable interrupts
for (;;); // Do nothing
return 0 ;
}
interrupt (UART1RX_VECTOR) usart1_rx (void)
{
while ((IFG2 & UTXIFG1) == 0); // USART1 TX buffer ready?
TXBUF1 = RXBUF1; // RXBUF1 to TXBUF1
}
/////// makefile ////////////////////////////////////////////////////////////////////////////////
# makfile configuration
NAME = bpv
OBJECTS = main.o
CPU = msp430x169
ASFLAGS = -mmcu=${CPU} -D_GNU_ASSEMBLER_
CFLAGS = -mmcu=${CPU} -O2 -Wall -g
#switch the compiler (for the internal make rules)
CC = msp430-gcc
AS = msp430-gcc
LD = msp430-ld
.PHONY: all FORCE clean download download-jtag download-bsl dist
#all should be the first target. it's built when make is run without args
all: ${NAME}.elf ${NAME}.a43 ${NAME}.lst
#confgigure the next line if you want to use the serial download
download: download-jtag
#download: download-bsl
#additional rules for files
${NAME}.elf: ${OBJECTS}
${CC} -mmcu=${CPU} -o $@ ${OBJECTS}
${NAME}.a43: ${NAME}.elf
msp430-objcopy -O ihex $^ $@
${NAME}.lst: ${NAME}.elf
msp430-objdump -dSt $^ >$@
download-jtag: all
msp430-jtag -e ${NAME}.elf
download-bsl: all
msp430-bsl -e ${NAME}.elf
clean:
rm -f ${NAME}.elf ${NAME}.a43 ${NAME}.lst ${OBJECTS}
#backup archive
dist:
tar czf dist.tgz *.c *.h *.txt makefile
#dummy target as dependecy if something has to be build everytime
FORCE:
#project dependencies
main.o: main.c