#include "msp430x24x.h"
char i;
char j;
char addr;
void delay (char t)
{
for(i=100;i>0;i--)
{
for(j=100;j>0;j--);
}
}
void init(void)
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600; (104)decimal = 0x068h
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}
void main (void)
{
WDTCTL = WDTPW + WDTHOLD;
init();
_EINT();
addr=0x01;
while(1)
{
for(addr=1;addr<=6;addr++)
{
while((IFG2&UCA0TXIFG)==1);
UCA0TXBUF=addr;
delay(35);
}
}
}
串口调试软件显示发出的数据是01 04的循环