#include <msp430x14x.h>
void main(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P5DIR |= 0x70; // P5.4 ,5.5 5.6 output direction
P5SEL|= 0x70; // P5.4 = MCLK option select;5.5=SMCLK;5.6=ACLK;
BCSCTL1 &= ~XT2OFF; // XT2 = HF XTAL
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=XT2CLK SMCLK=XT2CLK
UCTL0 = CHAR; // 8-bit character
UTCTL0 =SSEL1+SSEL0; //UCLK=SMCLK;
//BCSCTL2 |= SELM1; // MCLK = XT2 (safe)
//UCTL0 &=~ SWRST; // reset SWRST bit
//UTCTL0 = SSEL0; // UCLK = ACLK
UCTL0 = 0x10; //8 data bits, even parity, 1 stop bit
UBR00 = 0x41;
UBR01= 0x3;
//UBR10 = 0x00;
UMCTL0 = 0x03; //BDR=9600 ,8 M jingzhen
URCTL0= 0x00;
ME1 |= UTXE0 + URXE0; // Ena××e USART0 TXD/RXD
//IE1 |= URXIE0; // Ena××e USART0 RX interrupt
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
P3DIR |= 0x10; // P3.4 output direction
while(1)
{
TXBUF0=0x6f;
while ((IFG1 & UTXIFG0) == 0); // USART0 TX buffer ready?
for (i = 0xAFF; i > 0; i--);
}
}
这是我的程序 ,现在的问题是无论发什么都布是我要得到的结果
刚开始的时候还出现过正常的结果,可是后来出现的结果都是莫名其妙的,用示波器看刀232的管脚输出是对的,经过串口传输线输出也是对的,可是刀了机器上就布对,换了机器还是一样,还了串口调试工具结果还是一样,布知道是什么原因,高手赐教啊 |