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.

MSP430FR4133: UART Configuration help.

Part Number: MSP430FR4133
Other Parts Discussed in Thread: MSP430FR6877

Greetings,

I am attempting to establish communication between the MSP430FR4133 and MSP430FR6877 MCUs using UART. The MSP430FR4133 uses a 32.768 KHz external crystal for its operation. Below is a snippet of my code for UART initialization:

void initUART()
{

P1SEL0 |= (BIT0 | BIT1);
UCA0CTLW0 &= ~(UCSYNC);
UCA0CTLW0 |= UCSWRST;                 // Put eUSCI in reset
UCA0CTLW0 |= UCSSEL__UCLK;       // CLK = UCLK

UCA0BR0 = 3;                                       // 32000/9600
UCA0BR1 = 0x00;
UCA0MCTLW &= ~(UCOS16);
UCA0CTLW0 &= ~(UCSWRST);           // Initialize eUSCI
UCA0IE |= UCRXIE;

}

the string i am sending is as follows

guckfactor_array[8] = '\0';
guckfactor_array[7] = (((int) digit8) + 0x30);
guckfactor_array[6] = (((int) digit7) + 0x30);
guckfactor_array[5] = (((int) digit6) + 0x30);
guckfactor_array[4] = (((int) digit5) + 0x30);
guckfactor_array[3] = (((int) digit4) + 0x30);
guckfactor_array[2] = (((int) digit3) + 0x30);
guckfactor_array[1] = (((int) digit2) + 0x30);
guckfactor_array[0] = (((int) digit1) + 0x30);

initUART();
UARTPutString(guckfactor_array);

In the code, the string is constructed by assigning each digit to the array element and converting it to ASCII.

the snippet for sending data to the uart is as follows 


void UARTPutString(char *str)
{
unsigned int i=0;
while(str[i]!='\0') //check for NULL character to terminate loop
  {
   while(!(UCA0IFG & UCTXIFG));
   UCA0TXBUF = str[i];
   __delay_cycles(10);
   i++;
   }
}

However, when the first byte is written to UCA0TXBUF, the UCTXIFG flag is reset, but the UCTXCPTIFG flag remains unset. Consequently, the program enters an infinite loop at the while condition. It seems that the data is not being successfully transferred to the shift register by TXBUF.how do i know if the data is being put into the shift register by TXBUF? i dont see anything on PuTTY.what do i infer from this?.Please Review the code and suggest a solution.CCS version is 12.0.0
Thanks and Regards.
Pratik.

  • Did you clear LOCKLPM5?

    You have selected an external clock source via UCLK. Did you configure that pin? Your choices of internal clocks are SMCLK and MODCLK.

    Your initialization could could fail if called at any other time than just after a power up clear. UCSYNC is one of those bits that can't be changed unless UCSWRST is set. Which both are at power up.

    Your bit rate is not 9600. That would require setting the modulation bits. Not a problem if both MSP430s use the same settings. (If a modulation pattern is used, they must be identical.)

  • Thanks for your response David!
    Yes, i have cleared LOCKLPM5 in PMCTL0.
    and also configured the pin for SMCLK. And as you suggested i've moved the USYNC clearing part after Setting the UCSWRST.
    Now i am able to recieve data sent by the controller on Docklight(on my pc).
    However there seems to be a problem when i send data from pc to the controller.
    the controller doesnt jump into the isr for recieving data

    here's the updated uart init function for MSP430FR4133

    P1SEL0 |= (BIT0 | BIT1);
    UCA0CTLW0 |= UCSWRST;                       // Put eUSCI in reset
    UCA0CTLW0 &= ~(UCSYNC);
    UCA0CTLW0 |= UCSSEL__SMCLK;          // CLK = SMCLK
    UCA0BR0 = 0x68;                                       // 1000000/9600
    UCA0BR1 = 0x00;
    UCA0CTLW0 &= ~(UCSWRST);                 // Initialize eUSCI
    UCA0IE |= UCRXIE;


    The isr function is as follows

    #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_A1_VECTOR))) USCI_A1_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));
    gucrcvChar = UCA0RXBUF;
    gucRxBuffer[guiRXIndex] = gucrcvChar;
    guiRXIndex++;

    break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    }
    }



  • Are you enabling interrupts somewhere? (__enable_interrupt();)

**Attention** This is a public forum