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.

MSP430G2533无法进行串口通信

各位大神好

我使用了官方的例程

#include <msp430.h>

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0+UCBRS2; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}

// Echo back RXed character, confirm TX buffer is ready first
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0RX_VECTOR))) USCI0RX_ISR (void)
#else
#error Compiler not supported!
#endif
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}

使用的也是Launchpad这块开发板  但是我的串口调试助手就是无法接收数据,有遇到过这种情况的大神吗

PS:我跳线帽的设置也是正确的  串口设置也是没问题的

  • 您用的是2553吧?www.ti.com.cn/.../msp-exp430g2et 这个开发板?
  • 您好    我使用的是这块  可能不是最新版的

  • 您看 我下面已经发送了200多次了 还是没数据接收

  • 您的是下面链接内的,现在状态已经停产了

    www.ti.com.cn/.../MSP-EXP430G2

    我现在没有这个板子,请您看一下www.ti.com.cn/.../slau318g.pdf

    8 Frequently Asked Questions (FAQ) 的第5个问题

    5. I am not able to select the MSP430 Application UART and cannot receive data.
    Ensure that the Application UART driver is correctly installed. This is done by installing either IAR Embedded Workbench or Code Composer Studio v4. To determine if the driver is correctly installed:

    a. Plug in the MSP-EXP430G2 LaunchPad development kit with the included mini USB cable.
    b. Right click My Computer and select Properties.
    c. Select the Hardware tab and click on Device Manager.
    d. Under Ports (COM & LPT) should be an entry for "MSP430 Application UART (COM xx)".

    If the entry is there, but no characters are received, reconnect the LaunchPad development kit to the PC and restart the application to reload the drivers. If the Application UART is not listed, install the driver by following the instructions in Section 3.2.

    If the application UART is installed but not receiving UART data, ensure that the jumpers on J3 are configured for the proper UART communication. The two UART jumpers are configured vertically for a software (SW) UART, and horizontally for a hardware (HW) UART. The application implementation and J3 jumpers should match for UART data to be properly transmitted.
  • #include "msp430g2533.h"
    volatile int j;
    void UART0_send_byte(unsigned char data)    //发送一位
    {
    for( j=10000;j>0;j--);
    UCA0TXBUF=data;
    }
    
    
    void UART0_send_str(char *s)   //发送字符串
    {
        while(*s != '\0')
        {
            UART0_send_byte(*s++);
        }
    }
    
    
    void UART0()
    {
    DCOCTL = 0;                               // Select lowest DCOx and MODx settings
    BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
    DCOCTL = CALDCO_1MHZ;
    P1SEL |= BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD
    P1SEL2 |= BIT1 + BIT2 ;                   // P1.1 = RXD, P1.2=TXD
    UCA0CTL1 |= UCSSEL_2;                     // SMCLK
    UCA0BR0 = 104;                            // 1MHz 9600
    UCA0BR1 = 0;                              // 1MHz 9600
    UCA0MCTL = UCBRS0;                        // Modulation UCBRSx = 1
    UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    }
    int main()
    {
    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    if (CALBC1_1MHZ==0xFF)// If calibration constant erased
     {
       while(1);                               // do not load, trap CPU!!
     }
    UART0();
    
    while(1)
     {
    for(j=10000;j>0;j--);
    UART0_send_str("hello world!\n");
    
     }
    }
    

  • 试试这个例子可以用不