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.

CCS/MSP430FR6989: Clarity required to realize Back channel UART functionality

Part Number: MSP430FR6989
Other Parts Discussed in Thread: MSP-EXP430FR6989

Tool/software: Code Composer Studio

I am a beginner and trying to run the below program in MSP430FR6989 to access the back channel UART. But I face the following problems,

1. CCS displays 2 warnings stating , #2580-D pragma vector= accepts numeric arguments or "unused_interrupts" but not USCIAB0RX_VECTOR. 

2. With IE2 |= UCA0RXIE; CCS throws error and it is error free by using UCA0IE |= UCRXIE; 

Upon choosing the exact terminal with reference to device manager I could not see any data in the respective terminal. 

#include <msp430fr6989.h>
#include <stdio.h>

char string1[]="Hello /n /r";
char i=0;
char j =0;

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
PM5CTL0 = 0x00;

P3SEL0 |= BIT4 | BIT5;
P3SEL1 &= ~(BIT4 | BIT5);


UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600 = 3.41
UCA0BR1 = 0x00; //
UCA0MCTLW = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA0CTL1 &= ~UCSWRST;
UCA0IE |= UCRXIE;//IE2 |= UCA0RXIE;


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

}


#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)

{

UCA0TXBUF = string1[i++];

if (i == sizeof string1)
{
UCA0IE &= ~UCTXIE;//IE2 &= ~UCA0TXIE;
}
}


#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
string1[j++] = UCA0RXBUF;

if (j > sizeof string1 - 1)
{
i = 0;
j = 0;
UCA0IE &= ~UCTXIE;//IE2 |= UCA0TXIE;
UCA0TXBUF = string1[i++];
}
}

  • Did you try to copy code meant for a MSP430G2xx value-line device? You should be using the USCI_A1_ISR to handle both UCRXFIG and UCTXIFG requests. And I do mean UCA1 since this is the peripheral connected to the MSP-EXP430FR6989 backchannel UART on P3.4/P3.5. UCA1IE is the correct register name, not IE2. Right now your code uses VLOCLK to source ACLK, in which case the typical 9.4 kHz is not stable or fast enough for baud rate generation. The LFXT is not initialized for your intended BRCLK of 32 kHz. You also only reset UCTXIE so the UCTXIFG will never create a valid interrupt request (not that you need it for this use case anyways). Once all of the correct changes are made then the UCRXIFG ISR may be entered, but you need to first make sure that the UCTXIFG is set before loading a value into UCA1TXBUF. I suggest you review the msp430fr69xx_euscia0 code examples found from the Tools & software tab of the product page.

    Regards,
    Ryan
  • I wanted to know whether my interrupt calling is occurring so I declared P1OUT =0x01; to make sure LED toggles for the successful execution of transmit interrupt. 

    Program returns with no errors but LED is not toggled which in return assume my interrupt isn't called.

    #include <msp430fr6989.h>
    #include <stdio.h>

    char string1[]="Hello /n /r";
    char i=0;
    //char j =0;

    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    PM5CTL0 = 0x00;
    P1OUT =0x00;
    P1DIR |= BIT0;
    P3SEL0 |= BIT4 | BIT5;
    P3SEL1 &= ~(BIT4 | BIT5);

    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
    CSCTL4 &= ~LFXTOFF; // Enable LFXT1
    CSCTL5 &= ~LFXTOFFG; // Clear XT1 fault flag
    CSCTL0_H = 0; // Lock CS registers
                              //FRCTL0 = FRCTLPW | NACCESS_1

    // configuring UART module
    UCA1CTL1 |= UCSWRST; // reset
    UCA1CTL1 = UCSSEL__ACLK; // CLK = ACLK
    UCA1BR0 = 3; // 32768/9600 = 3.41333
    UCA1BR1 = 0x00;
    UCA1MCTLW = 0x5300; // UCBRSx setting from fractional part of N
    UCA1CTL1 &= ~UCSWRST; // set
    UCA1IE &= ~UCRXIE; //IE2 |= UCA0RXIE;

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

    }


    #pragma vector=USCI_A1_VECTOR 
    __interrupt void USCI_A1_ISR (void) 

    {
    P1OUT =0x01;               // Toggle LED - to check the execution of interrupt calling
    UCA0TXBUF = string1[i++];

    if (i == sizeof string1)
    {
    UCA1IE &= ~UCTXIE; //IE2 &= ~UCA0TXIE;
    }
    }

    //interrupt for receive but ignored for time being
    /*#pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR (void)
    {
    string1[j++] = UCA0RXBUF;

    if (j > sizeof string1 - 1)
    {
    i = 0;
    j = 0;
    UCA1IE &= ~UCTXIE; //IE2 |= UCA0TXIE;
    UCA0TXBUF = string1[i++];
    }
    }*/

  • 1) You're not setting UCA1IE:UCTXIE, so you won't get a Tx interrupt.
    2) You're running the UART from VLOCLK, which isn't accurate enough (not even close) for a UART. I suggest SMCLK.
    3) LPM3 turns off a collection of stuff, which confuses things. I suggest you start with LPM0.
  • I made the above changes, it was  silly mistake to leave out the transmit enable. Now my ccs stats -  "USCI_A1_ISR" has already been defined.

    I can understand theoretically whats happening here, but I could not solve this issue. I need help in defining my receive interrupt so that I can view the transmit and receive of characters in my configured terminal.

     

    #include <msp430fr6989.h>
    #include <stdio.h>

    char string1[]="Hello /n /r";
    char i=0;
    char j =0;

    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    PM5CTL0 = 0x00;
    P1OUT =0x00;
    P1DIR |= BIT0;
    P9OUT =0b00000000;
    P9DIR =0b10000000;
    P3SEL0 |= BIT4 | BIT5;
    P3SEL1 &= ~(BIT4 | BIT5);

    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
    CSCTL4 &= ~LFXTOFF; // Enable LFXT1
    CSCTL5 &= ~LFXTOFFG; // Clear XT1 fault flag
    CSCTL0_H = 0; // Lock CS registers
    //FRCTL0 = FRCTLPW | NACCESS_1

    // configuring UART module
    UCA1CTL1 |= UCSWRST; // reset
    UCA1CTL1 = UCSSEL__SMCLK; // CLK = SMCLK
    UCA0BR0 = 52;
    UCA0BR1 = 0x00;
    UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
    UCA1CTL1 &= ~UCSWRST;
    UCA1IE &= ~UCRXIE;
    UCA1IE= UCTXIE;

    __bis_SR_register(LPM0_bits + GIE);

    }


    #pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR (void)

    {
    P1OUT =0x01; // Toggle LED - to check the execution of interrupt calling
    UCA0TXBUF = string1[i++];

    if (i == sizeof string1)
    {
    UCA1IE &= ~UCTXIE;
    }

    }
    #pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR (void)
    {
    P9OUT =0b10000000;
    string1[j++] = UCA0RXBUF;

    if (j > sizeof string1 - 1)
    {
    i = 0;
    j = 0;
    UCA1IE &= ~UCTXIE;
    UCA0TXBUF = string1[i++];
    }
    }

  • As Ryan pointed out, the FR6xx have a single vector (ISR function) for Tx and Rx. (This is different from e.g. the G2xx MCUs.) You need to combine your two functions and check the TXIFG/RXIFG flags to see what triggered it.

    You also need to set UCA1IE:UCRXIE to get Rx interrupts.

    Are you seeing your "Hello" string? If not, you may want to take a moment to diagnose that first. If the UCA is mis-configured you may or may not see Rx interrupts.
  • Please evaluate the msp430fr69xx_euscia0_uart example code and build up your application from there.

    Regards,
    Ryan
  • I tried reading the msp430fr69xx_euscia0_uart example code but it didnt help me to understand the part of using single interrupt for Tx and Rx.  there isnt an example involving both and a sample code will be highly useful to understand the working. I want to send and receive the string for the above program using back channel UART (P3.4, P3.5)

    Thanks in advance.

  • The code example just shows what your EUSCIA0 initialization and ISR is supposed to look like, most applications choose to simply check if the TXBUF is empty before populating it as compared to using the TX interrupt (flags when TXBUF is ready for more data).

    Regards,
    Ryan

**Attention** This is a public forum