This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430f1611串口通信问题

Other Parts Discussed in Thread: MSP430F169, MSP430F1611

#include "uart.h"

void uart0_Init()
{
U0CTL |= SWRST;
U0CTL |= CHAR;
U0TCTL |= SSEL1;//子时钟SMCLK

U0BR0=0X41;
U0BR1=0X03;
U0MCTL=0x07;

ME1 |= UTXE0 + URXE0; //使能 模块 发送 传输 功能

U0CTL &= ~SWRST;
IE1 |= URXIE0;
/*P3.4 P3.5 用于 UART0 */
P3SEL |= 0X30;
}

void uart0_sendstring(char *p , int n)
{
for (int i=n;i>0;i--)
uart0_sendchar(*p++);
}

void uart0_sendchar(char c)
{
while( !(U0TCTL & TXEPT ));
U0TXBUF = c;
}

char uart0_getchar()
{
return U0RXBUF;
}

#pragma vector=USART0RX_VECTOR
__interrupt void usart0_rx()
{
while(! IFG1 & UTXIFG0);
TXBUF0 = RXBUF0;
//uart0_sendstring("UART0\n", 6);
//char c=uart0_getchar();
//uart0_sendchar(c);
}

void main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT
SysClockInit();
uart0_Init();

//uart1_Init();

uart0_sendstring("dfdfsdf\n", 8);
int i=2;
while(i)
{
//uart0_sendstring("UART0world\n", 11);
//i--;
}

}

串口存在的问题:

1. 在主函数main()  中,上电复位调用uart0_sendstring("dfdfsdf\n", 8) ,串口精灵有时可以收到,有时收不到

2.通过串口精灵 发送输送数据给单片机, 单片机有时接收成功返回,有时直接接收不到, 接收成功返回的概率 很低。

3.本程序可以很稳定的在 msp430f169上运行, 在看了msp430f1611的勘误表后,

When using the USART in UART mode with UxBR0 = 0x03 and UxBR1 = 0x00, the start
edge of received characters may be ignored due to internal timing conflicts within the
UART state machine. This condition does not apply when UxBR0 is > 0x03.

已经避免了这个问题,为什么 还是存在问题。