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.

MSP430F5528: UART

Part Number: MSP430F5528


Hi,

I am configuring a UART communication with rf transmitter. Below is the code:

#include <stdio.h>
#include <msp430.h>
void main()
{
    WDTCTL = WDTPW | WDTHOLD;       // stop watchdog timer
    P4SEL |= 0x30; // P4.4,5 = USART0 TXD/RXD
    P4DIR |= 0x90;
    UCA1CTL1 |= UCSWRST;
    UCA1CTL1 |=UCSSEL_2;
    UCA1BR0=0x03;
    UCA1BR1=0x00;
    UCA1MCTL=0x03;
    UCA1CTL1 &= ~(UCSWRST);
    UCA1IE|= UCTXIE ;

 while (!(UCA1IFG & UCTXIFG)); // USART0 TX buffer ready?
    {
    UCA1TXBUF = 0x42;
    
}
}

In the above code I have selected UCA1TXD pin. Baud rate is 9600 and here I am transferring one byte 42.  In receiver section I have programmed accordingly. I have written this after studying msp430f5528 users' guide. Transmitter and receiver modules are working because I have programmed in other MCU and it is working fine. Please help me in this.

 

  • Hi Pabel, do you have programmed the interrupt service routine right?

    You have enabled the UCTXIE, but could not see any interrupt service routine in your code.

  • Hi,

    I don't need that. I need only UCTXIFG interrupt and that I am checking in code.

    #include <stdio.h>
    #include <msp430.h>
    void main()
    {
        WDTCTL = WDTPW | WDTHOLD;       // stop watchdog timer
        P4SEL |= 0x30; // P4.4,5 = USART0 TXD/RXD
        P4DIR |= 0xD0;
        UCA1CTL1 |= UCSWRST;
        UCA1CTL1 |=UCSSEL_2;
        UCA1BR0=0x03;
        UCA1BR1=0x00;
        UCA1MCTL=0x03;
        UCA1CTL1 &= ~(UCSWRST);
    
    
     if (!(UCA1IFG & UCTXIFG)); // USART0 TX buffer ready?
        {
        UCA1TXBUF = 0x85;
        P4OUT |=BIT6;
    }
    }
    

    Please help..

**Attention** This is a public forum