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.

G2553 hardware UART mode on launchpad Rev 1.4

Other Parts Discussed in Thread: MSP430G2553

Hi,


I'm trying to send fixed data to PC using UART. I just want to receive data from msp430. Now I guess there may be two things I'm doing wrong.


1. I have launchpad Rev 1.4 and I'm using msp430g2553 on it. I set the J3's TxD and RxD pin vertical as suggested by some posts.

2. Here is my code. In the code I'm writing fixed data to UCA0TXBUF=0x45 and checking the TXIFG flag to see if the data is sent or not. If its sent then LED will be on.


I'm not getting anything on my PC. I tried using putty.

#include <msp430.h> 

/*
 * main.c
 */
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
    DCOCTL = 0;
    BCSCTL1 = CALBC1_1MHZ;
    DCOCTL = CALBC1_1MHZ;

    P1DIR = BIT6;
    P1OUT &=~BIT6;

    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;		// enable the usci module

    UCA0TXBUF = 0x45;		//data transmission initiated

    __bis_SR_register(LPM0 + GIE);

    while (1)
    {
//    	UCA0TXBUF = 0x45;		//data transmission initiated
    	if ((IFG2 & UCA0TXIFG) == 1) // check if the TXBUF is empty
    		P1OUT |= BIT6;
    	else
    		P1OUT |=BIT0;
    }

}

  • As I recall, using the hardware UART on Rev 1.4 requires cross-connecting the jumpers (X-shaped), effectively reversing P1.1 and P1.2. Check the schematics in the back of the User Guide (or just try it).

    if ((IFG2 & UCA0TXIFG) == 1)
    

    This condition will never be true, since UCA0TXIFG = 2. Try

    if (IFG2 & UCA0TXIFG)

  • Hi,


    thanks for replying back. How can TXIFG will be 2? its just a flag and it is set when the TCXBUF is ready to accept the character. Do you think rest of the code is correct? I tried setting the jumper connection in various positions but its not working? any suggestions?

  • msp430g2553.h, line 167:

    #define UCA0TXIFG              (0x02)

    (See also User Guide 15.4.13.)

    Some processors (8051, e.g.) have bit-addressable flags, but most, including the MSP430, don't -- UCA0TXIFG is just a bit in a register.

    The  Rev 1.4 Launchpads were designed with a software UART in mind; the software UART needed the timer pins, which were (effectively) opposite to the hardware UART pin assignments which came later. I recall having to use jumper wires to make an X-shape for Rx/Tx since I always used the hardware UART. For Rev 1.5, they came up with the "rotating" jumpers, which is much more convenient.

    On a second look, I see that your program (before the loop) goes into LPM0 with no interrupt sources enabled, so it will never make it to the loop. You probably want to remove that line for now.

    Also, the "else" clause in the loop turns on P1.0, but since it's an input that will have no effect. If your intent was to light the other LED, you should probably set P1DIR|=BIT0.

  • Hi,


    Thanks. I now understood the problem. I have launchpad Rev 1.4 and for that I have to make X shape for the jumper to use UART in hardware mode. Thanks for your help.

**Attention** This is a public forum