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.

MSP430FR5994: Launch Pad Uart does not work correctly

Part Number: MSP430FR5994

Dear Sirs:

     Have not been able to make the uart operate using this launch pad.  I've tried two simple programs from the post.

 

 

    The following is the code for a uart echo program for the MSP430FR5994 launch pad:

This Version, Version A, uses P2 and UCA0 uart.  It will receive a character correctly and a receive interrupt is generated.  But it will not transmit anything  (a scoped):  Testing with the launch pad uart.

#include <msp430.h>

 

/*

 * main.c

 */

int main(void) {

    WDTCTL = WDTPW | WDTHOLD;       // Stop watchdog timer

      

    // Configure GPIO

    P2SEL0 |= BIT0 | BIT1;                    // USCI_A0 UART operation

    P2SEL1 &= ~(BIT0 | BIT1);

 

    // Disable the GPIO power-on default high-impedance mode to activate

    // previously configured port settings

    PM5CTL0 &= ~LOCKLPM5;

 

    // Startup clock system with max DCO setting ~8MHz

    CSCTL0_H = CSKEY >> 8;                    // Unlock clock registers

    CSCTL1 = DCOFSEL_3 | DCORSEL;             // Set DCO to 8MHz

    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;

    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers

    CSCTL0_H = 0;                             // Lock CS registers

 

    // Configure USCI_A0 for UART mode

    UCA0CTLW0 = UCSWRST;

    UCA0CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK

    // Baud Rate calculation

    // 8000000/(16*9600) = 52.083

    // Fractional portion = 0.083

      // UCBRFx = int ( (52.083-52)*16) = 1

    UCA0BR0 = 52;                             // 8000000/16/9600

    UCA0BR1 = 0x00;

    UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900;

    UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI

    UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

    UCA3TXBUF =0x41;                        //test send 'a'                               this does nothing!

    __bis_SR_register(LPM3_bits | GIE);       // Enter LPM3, interrupts enabled

    __no_operation();                         // For debugger

  }

 

  #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)

  #pragma vector=USCI_A0_VECTOR

  __interrupt void USCI_A0_ISR(void)

  #elif defined(__GNUC__)

  void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)

  #else

  #error Compiler not supported!

  #endif

  {

    switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))

    {

      case USCI_NONE: break;

      case USCI_UART_UCRXIFG:

        while(!(UCA0IFG&UCTXIFG));

        UCA0TXBUF = UCA0RXBUF;            //program gets here on received char but nothing comes out the tx pin

        __no_operation();

        break;

      case USCI_UART_UCTXIFG: break;

      case USCI_UART_UCSTTIFG: break;

      case USCI_UART_UCTXCPTIFG: break;

    }

 

}

 

---------------------------------------------------------------------------------------------------------------------------------------

 

 

This version, version B,  uses P6 and UCA3.  It can transmit out P6.0 but does not receive on P6.1.  Also no interrupts are generated:

 

#include <msp430.h>

 

 

int TempStat;

 

/*****************************************************************************************************************************

 * main.c

 *

 *****************************************************************************************************************************/

int main(void) {

    WDTCTL = WDTPW | WDTHOLD;       // Stop watchdog timer

      

    // Configure GPIO

    P6SEL0 |= BIT0 | BIT1;                    // USCI_A0 UART operation

    P6SEL1 &= ~(BIT0 | BIT1);

 

    // Disable the GPIO power-on default high-impedance mode to activate

    // previously configured port settings

    PM5CTL0 &= ~LOCKLPM5;

 

    // Startup clock system with max DCO setting ~8MHz

    CSCTL0_H = CSKEY >> 8;                    // Unlock clock registers

    CSCTL1 = DCOFSEL_3 | DCORSEL;             // Set DCO to 8MHz

    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;

    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers

    CSCTL0_H = 0;                             // Lock CS registers

 

    // Configure USCI_A0 (int flags 30.3.15.4) for UART mode:

    UCA3CTLW0 = UCSWRST;                        //soft rst enable

    UCA3CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK

    // Baud Rate calculation

    // 8000000/(16*9600) = 52.083

    // Fractional portion = 0.083

      // UCBRFx = int ( (52.083-52)*16) = 1

    UCA3BR0 = 52;                             // 8000000/16/9600

    UCA3BR1 = 0x00;

    UCA3MCTLW |= UCOS16 | UCBRF_1 | 0x4900;

    UCA3CTLW0 &= ~UCSWRST;                    // Initialize eUSCI

    UCA3IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt (int flag reg 30.4.10)

 

    TempStat=UCA3CTLW0 ;                    //read ctl word 0

 

    TempStat=UCA3IFG ;                          //read int flags

    UCA3TXBUF =0x41;                        //test send 'a'

 

    __bis_SR_register(LPM3_bits | GIE);       // Enter LPM3, interrupts enabled

    __no_operation();                         // For debugger

  }

 

  #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)

  #pragma vector=USCI_A0_VECTOR

  __interrupt void USCI_A0_ISR(void)

  #elif defined(__GNUC__)

  void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)

  #else

  #error Compiler not supported!

  #endif

  {

    switch(__even_in_range(UCA3IV, USCI_UART_UCTXCPTIFG))

    {

      case USCI_NONE: break;

      case USCI_UART_UCRXIFG:                       //2

        TempStat=UCA3IFG ;                          //read int flags

        while(!(UCA3IFG & ~UCTXIFG));                  //30.4.11

        UCA3TXBUF = UCA3RXBUF;                      //echo

        TempStat= UCA3TXBUF;                        //see what's in there

        __no_operation();

        break;

      case USCI_UART_UCTXIFG:

          TempStat=UCA3IFG ;                          //read int flags

          UCA3TXBUF =0x42;                        //test send 'b'

          break;

 

      case USCI_UART_UCSTTIFG: break;

      case USCI_UART_UCTXCPTIFG: break;

    }

 

}

 

  • >P2SEL0 |= BIT0 | BIT1; // USCI_A0 UART operation
    >P2SEL1 &= ~(BIT0 | BIT1);

    According to SLASE54B Table 6-23 you need the P2SEL0 bits to be 0 and P2SEL1 bits to be 1. This setting hands the pins to TB0 instead. This is opposite to the UCA3/P6SELx settings (Table 6-32).

    Coming soon:
    > while(!(UCA3IFG & ~UCTXIFG)); //30.4.11
    This will probably spin forever. You probably want
    > while(!(UCA3IFG & UCTXIFG)); //30.4.11

    > UCA3TXBUF =0x41; //test send 'a' this does nothing!
    This uses the wrong UART. You probably want
    > UCA0TXBUF =0x41; //test send 'a' this does nothing!

    There should be sample code (including UART) available at the MSP43FR5994 page ("Tools and Software" tab most likely). It may also be possible to download this code directly into CCS using its Resource Explorer (or some such).
  • Thanks, Bruce McKenney47378, you're a lifesaver!

       Obviously I didn't understand the selects but you got me started.

    The code used that finally worked is:

    /*****************************************************************************************************************************
    * main.c Uses P2
    *
    *****************************************************************************************************************************/
    int main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    // Configure GPIO
    P2SEL0 &= ~(BIT0 | BIT1);
    P2SEL1 |= BIT0 | BIT1; // USCI_A0 UART operation

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    // Startup clock system with max DCO setting ~8MHz
    CSCTL0_H = CSKEY >> 8; // Unlock clock registers
    CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
    CSCTL0_H = 0; // Lock CS registers

    // Configure USCI_A0 for UART mode
    UCA0CTLW0 = UCSWRST;
    UCA0CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
    // Baud Rate calculation
    // 8000000/(16*9600) = 52.083
    // Fractional portion = 0.083
    // UCBRFx = int ( (52.083-52)*16) = 1
    UCA0BR0 = 52; // 8000000/16/9600
    UCA0BR1 = 0x00;
    UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
    UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
    UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

    UCA0TXBUF = 0x41; //test send 'A'

    __bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled
    __no_operation(); // For debugger
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
    while(!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = UCA0RXBUF; //echo
    __no_operation();
    break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    }

    }

    John

         

  • Refer to previous message.

**Attention** This is a public forum