连续跑在串口上面没东西显示 不知道是怎么回事
#include "msp430x54x.h"
void init_uart(void);
void init_clock(void);
/****************************************************************
串口发送字符串函数
****************************************************************/
void UartTX_Send(unsigned char *Data,int len)
{
int j;
for(j=0;j
{
while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF =*Data++;
}
}
void main(void)
{
unsigned char a[10]="hello";
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
init_clock();
init_uart();
// __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
UartTX_Send(a,5);
__no_operation();
}
void init_clock(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P11DIR = BIT0+BIT1+BIT2; // P11.1-2 to output direction
P11SEL |= BIT0+BIT1+BIT2; // P11.1-2 to output SMCLK,MCLK
P5SEL |= 0x0C; // Port select XT2
UCSCTL6 &= ~XT2OFF; // Ena××e XT2 even if not used
UCSCTL3 |= SELREF_2; // FLLref = REFO
UCSCTL4 |= SELA__XT2CLK;//辅助系统时钟来源XT2-16M
UCSCTL4 |= SELS_5 + SELM_5; // SMCLK=MCLK=XT2-16M
_NOP();
UCSCTL5 |= DIVM__2 + DIVS__16+DIVA__16; //主系统时钟2分频-8M;子系统时钟16分频-1M;辅助系统时钟16分频1M
/*do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
for(i=0;i<0xFFFF;i++); // Delay for Osc to stabilize
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
*/ 如果不屏掉的话就一直停在这里面 为啥呢?
}
void init_uart(void)
{
P5SEL |= 0xC0; // P5.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL__SMCLK; // SMCLK
UCA1BR0 = 0x08; // 1MHz 115200 (see User's Guide)
UCA1BR1 = 0x00; // 1MHz 115200
UCA1MCTL |= UCBRS_6+UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCTXIE; // Enable USCI_A1 RX interr
UCA1IFG = 0X02; //.........
//_EINT();
} |