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.

MSP430F2410: Unable to transmit on UART0 when both UART 1 and UART 0 are enabled

Part Number: MSP430F2410


When we enable both UART1 and UART0 we can’t transmit (nothing is seen on the putty) on UART0. However, we comment enabling UART 1, then we can see what is transmitted on UART0 (can see it  on Putty).  However, when both are enabled we can see what is transmitted in UART1. Any ideas?

Thanks

#define UART_MODE SMCLK_9600

char wel[] = "Welcome to serial programming";

 

 

void initClockTo1MHz()

{

    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;

}

 

void initGPIO_UART0()

{

    P3SEL = BIT4 | BIT5;        //Set P3.4 as UART 0 TXD and P3.5 as UART 0 RXD

}

 

void initGPIO_UART1()

{

    P3SEL = BIT6 | BIT7;        //Set P3.6 as UART 1 TXD and P3.7 as UART 1 RXD

}

void init_UART0()

{

    UCA0CTL1 |= UCSWRST;        //put the state machine in RESET

    UCA0CTL0 = 0;               //select UART MODE NO PARITY 8 bits Asynchronous

#if (UART_MODE == SMCLK_9600)

    UCA0CTL1 |= UCSSEL_2;       //choose 1MHz SCLK

 

    //Baud rate 9600 settings

    UCA0BR0 = 104;              //settings for 9600 baud

    UCA0BR1 = 0;

    UCA0MCTL = 2;

     __delay_cycles(20000);

    UCA0CTL1 &= ~UCSWRST;       //put UART in operation mode

    UC0IE |= UCA0RXIE;          // Enable USCI_A1 RX interrupt

#elif (UART_MODE ==SMCLK_19200 )

    UCA1CTL1 |= UCSSEL_2;       //choose 1MHz SCLK

    //Baud rate 19200 settings

    UCA0BR0 = 52;               //settings for 19200 baud

    UCA0BR1 = 0;

    UCA0MCTL = 0;

    __delay_cycles(20000);

    UCA0CTL1 &= ~UCSWRST;       //put UART in operation mode

    UC0IE |= UCA0RXIE;          // Enable USCI_A1 RX interrupt

 

#endif

}

void init_UART1()

{

    UCA1CTL1 |= UCSWRST;        //put the state machine in RESET

    UCA1CTL0 = 0;               //select UART MODE NO PARITY 8 bits Asynchronous

#if (UART_MODE == SMCLK_9600)

    UCA1CTL1 |= UCSSEL_2;       //choose 1MHz SCLK

 

    //Baud rate 9600 settings

    UCA1BR0 = 104;              //settings for 9600 baud

    UCA1BR1 = 0;

    UCA1MCTL = 2;

     __delay_cycles(20000);

    UCA1CTL1 &= ~UCSWRST;       //put UART in operation mode

    UC1IE |= UCA1RXIE;          // Enable USCI_A1 RX interrupt

#elif (UART_MODE ==SMCLK_19200 )

    UCA1CTL1 |= UCSSEL_2;       //choose 1MHz SCLK

    //Baud rate 19200 settings

    UCA1BR0 = 52;               //settings for 19200 baud

    UCA1BR1 = 0;

    UCA1MCTL = 0;

    __delay_cycles(20000);

    UCA1CTL1 &= ~UCSWRST;       //put UART in operation mode

    UC1IE |= UCA1RXIE;          // Enable USCI_A1 RX interrupt

 

#endif

}

 

/*!

 * \brief sends a character to UART

 *

 *   @param c - chacater to be sent

 *

 */

void sendCharUART1(char c)

{

    while (!(UC1IFG&UCA1TXIFG));               // USCI_A1 TX buffer ready?

     UCA1TXBUF = c;

}

 

 

/*!

 * \brief sends the given set of bytes into UART0

 *

 *  @param buf - pointer to a buffer which needs to be transmitted

 * @param len - number of bytes in the buffer that needs to be transmitted

 *

 */

void transmitPktUART0(char *buf, unsigned int len)

{

    unsigned int i =0;

    while (i<len){

                   UCA0TXBUF = buf[i];

                   while (UCA0STAT&UCBUSY );

                   i++;

    }

    UCA0TXBUF = 0x0a;

    while (UCA0STAT&UCBUSY );

    UCA0TXBUF = 0x0d;

    while (UCA0STAT&UCBUSY );

}

/*!

 * \brief sends the given set of bytes into UART1

 *

 *  @param buf - pointer to a buffer which needs to be transmitted

 * @param len - number of bytes in the buffer that needs to be transmitted

 *

 */

void transmitPktUART1(char *buf, unsigned int len)

{

    unsigned int i =0;

    while (i<len){

                   UCA1TXBUF = buf[i];

                   while (UCA1STAT&UCBUSY );

                   i++;

    }

    UCA1TXBUF = 0x0a;

    while (UCA1STAT&UCBUSY );

    UCA1TXBUF = 0x0d;

    while (UCA1STAT&UCBUSY );

}

 

int main(void)

{

    volatile char i = 0;

 

    WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer

    initClockTo1MHz();          //initialize the clock

    initGPIO_UART0();           //Initialize the GPIO port used for UART0

    init_UART0();               //initialize the UART0

    //initGPIO_UART1();           //Initialize the GPIO port used for UART1

    //init_UART1();                //initialize the UART1

 

    UC1IE = 0x01;          //enable RX interrupt

   

 

    transmitPktUART0(wel,10);

**Attention** This is a public forum