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.

MSP-EXP430FR6989: Uart_A0_ and driverlib example

Part Number: MSP-EXP430FR6989

From Resource explorer, I import the msp430fr69xx_eusci_uart_standard_transceiver C project. I jumper P2.- and P2.1 pins to RX and TX on the launchpad and from the terminal, I can send and receive the correct character. 

Then I import the eusci_a_uart_ex1_loopbackAdvanced project (driverlib)  I copy the interrupt functions from the above project but I got many errors on the serial port.

I have some questions.

a) the code below from the working project

// Configure UART
        P2SEL0 |= BIT0 | BIT1;                    // USCI_A0 UART operation
        P2SEL1 &= ~(BIT0 | BIT1);
UCA0CTLW0 |= UCSSEL__ACLK;               // CLK = ACLK
        // Baud Rate calculation
        // 32768/(9600) = 3.4133
        // Fractional portion = 0.4133
        // Use Table 24-5 in Family User Guide
        UCA0BR0 = 3;                             // 32768/9600
        UCA0BR1 = 0;
        UCA0MCTLW |= 0x9200;    //0x9200 is UCBRSx = 0x92
        UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
        UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

As I can see the code below -using the driverlib- do the same but it has too many errors on the serial port

 GPIO_setAsPeripheralModuleFunctionInputPin(
    GPIO_PORT_P2,
    GPIO_PIN0 + GPIO_PIN1,
    GPIO_SECONDARY_MODULE_FUNCTION
    );
// Configure UART
    EUSCI_A_UART_initParam param = {0};
    param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_ACLK;
    param.clockPrescalar = 3;
    param.firstModReg = 0;
    param.secondModReg = 0x92// the source code has the value 92 not 0x92     is it a typograhic error?
    param.parity = EUSCI_A_UART_NO_PARITY;
    param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
    param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
    param.uartMode = EUSCI_A_UART_MODE;
    param.overSampling = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;

    if (STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &param)) {
        return;
    }
    EUSCI_A_UART_enable(EUSCI_A0_BASE);
    EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE,      EUSCI_A_UART_RECEIVE_INTERRUPT);

    // Enable USCI_A0 RX interrupt
    EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,
                                 EUSCI_A_UART_RECEIVE_INTERRUPT);                     // Enable interrupt

the rest of the code is the same at two projects

    __enable_interrupt();

    while (1)
    {
      
        __bis_SR_register(LPM3_bits + GIE);       // Since ACLK is source, enter LPM3, interrupts enabled
    }
}
//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************

#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;
     // P1OUT ^=BIT0;
      __no_operation();
      break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
  }
}

b) GPIO_setAsPeripheralModuleFunctionInputPin at
driverlib ver  2.91.13.01  the  accepts 2 params

can you give me more information about that?

c) I want to use Uart_A1 ( P3.4 and P3.5 ) which is the piece of code to do the same for P3.4 and P3.5 with the drivelib?

  • Hi,

    1) I think you are right. It should be 146 or 0x92, you can see it more clearly from this website:http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html

    2) You can refer to this, what it do is to assign mode to  P2SELx

    3) You need to change the setting of PIN, then change all USCA0 to USCA1. Remember to change the interrupt name"USCI_A0_VECTOR". It should be OK.

    Please make a try.

  • a) 0x92 should be correct. You can see the msp430fr69xx_eusci_uart_standard_transceiver.c code. There is also 0x9200. 

    b) Please check Driverlib user's guide. There are 3 input parameters for this function, and there are detailed description for this function parameters. 

    void GPIO_setAsPeripheralModuleFunctionOutputPin ( uint8_t selectedPort, uint16_t selectedPins, uint8_t mode )

    c) It is no problem. 

    GPIO_setAsPeripheralModuleFunctionOutputPin (

        GPIO_PORT_P3,
        GPIO_PIN4 + GPIO_PIN5,
        GPIO_SECONDARY_MODULE_FUNCTION
     )

  • for (1) ok.

    for (3) ok, already I do that for Uart_A1. I changed the appropriate numbers

    for (2) The problem is that the help file, see the photo above require 2 params

    With a new project  the function require 3 params GPIO_setAsPeripheralModuleFunctionInputPin(selectedPort, selectedPins, mode). Anyway. Can you tell me how I will find which is the primary, the secondary, and ternary module for a pin eg P3.4  For Uart_A1 I have to set P3.4 GPIO_setAsPeripheralModuleFunctionOutPin for Tx and P3.5 as input for  Rx Is that correct?

  • the code with driverlib does not work well. I use the simple way

    for (b) please check this

    software-dl.ti.com/.../group__gpio__api.html

    this is "live"  from Ti site, please tell the support team to synchronize the documents

  • Hi,

    You can refer to the datasheet that the UART setting has no relationship with the Input or output setting. That means you can use either  GPIO_setAsPeripheralModuleFunctionInputPin or  GPIO_setAsPeripheralModuleFunctionOutputPin. That is why the code example use GPIO_setAsPeripheralModuleFunctionInputPin to set two UART ports.

    For the primary, the secondary, and ternary module. That related to P3SELx. For secondary it means P3SEL0=1, P3SEL1=0. That is what you should choose for P3.4 and P3.5

    Eason

**Attention** This is a public forum