|
下面的程序大家帮忙看看,现在通过串口调试助手想从单片机上接收发送来的字符串,但是总是出现乱码,是不是波特率出错,还是程序本身有问题,谢谢。。晶振是8MHZ,波特率9600
#include <msp430x13x.h>
char Data[6]="123456";
char rece[7];
int count=0,f=0;
void HELLO(void)
{
unsigned char i;
for(i=0;i<6;i++)
{
while((IFG1&UTXIFG0)==0);
TXBUF0=Data[i];
}
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
UTCTL0|=SSEL1;
UBR00=0x69;
UBR10=0x03;
UMCTL0=0xDB;
ME1|=UTXE0+URXE0;
UCTL0|=CHAR;
UCTL0 &= ~SWRST;
IE1|=URXIE0;
P3DIR|=0x10;
P3SEL|=0x30;
_EINT();
for(;;)
{
if(f==0)
{
HELLO();
f=1;
}
}
}
#pragma vector=UART0RX_VECTOR
__interrupt void USART0_RX(void)
{
rece[count]=RXBUF0;
count++;
if(count==6)
count=0;
}
|
|