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/MSP430FR4133: MSP430FR4133

Part Number: MSP430FR4133

Tool/software: Code Composer Studio

Hi

I am new to CCS, and I am having trouble in configuration/ initialization of UART. I referred slau445g for initiating the registers.

My primary aim is to transmit a single byte/ buffer(if possible) to comp port, attaching code for persual. Any help would be really appriciated.

//#include <classic.h>
#include <msp430.h>
#define DELAY 10000

unsigned int txint=12;

void txdata(unsigned int txint){

//UCA0IFG |= 0x02;
//while(UCA0TXIFG)
UCA0TXBUF = 0x01;
}

void init_uart(void){
P1SEL0 |=(BIT0 |BIT1);

UCA0CTLW0 |= UCSWRST;

UCA0CTLW0 |= UCSSEL__SMCLK;

UCA0BR0 = 104; // 16000000/16*9600

UCBRSx=0x49;

UCA0BR1 = 0x00;

UCA0MCTLW = UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST;

UCA0IE |= UCRXIE;

RTCCTL &= ~RTCIE;
}

void init_delay(int l){
int i;
for(i=0;i>l;i++);
}

int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

init_uart();

while(1)
{
txdata(txint);
init_delay(DELAY);
}

}

Thank you

  • Hi Onkar,

    You are missing all of the CSCTLx register initialization necessary to set SMCLK to 16 MHz as desired, please review msp430fr413x_CS_[03/05].c and msp430fr413x_euscia0_uart_[01/03].c for more information. You are also not disabling the GPIO power-on default high-impedance mode to activate previously configured port settings (PM5CTL0 &= ~LOCKLPM5;) and evaluating for an empty UCTX buffer (while(!(UCA0IFG&UCTXIFG));) is preferable to a random delay.

    Regards,
    Ryan
  • Thank you for your answer.

    Can we not take the default value of BRCLK/ SMCLK and do the calculations for baud rate? If yes how? If not why?

    Thanks and regards

    Onkar

  • This is possible Onkar, but the default SMCLK frequency is 1 MHz whereas your setup indicates the desire to operate SMCLK at 16 MHz (see msp430fr413x_euscia0_uart_03.c). Recommended settings for typical baud rates are provided in Table 21-5 of the User's Guide.

    Regards,
    Ryan
  • Thank you for your valuable response
    Regards
    Onkar
  • Sir there is one error that I faced recently

    I reconsidered the calculations for defining the baut rate but still i m getting garbage values at tx. Are there any corrections in the calculation

    void init_uart()
    {
    P1SEL0 |=(BIT0 |BIT1);
      P1DIR = BIT0; // P1.1 = RXD, P1.2=TXD
      // Configure UART
        UCA0CTLW0 |= UCSWRST;
        UCA0CTLW0 |= UCSSEL__SMCLK;
        UCA0BR0 = 6;                             // 1000000/16/9600
        UCA0BR1 = 0x00;
        UCA0MCTLW = 0x4980 | UCOS16;
        UCA0CTLW0 &= ~UCSWRST;
    }
    This is just init_uart() function. I disabled the high impedance mode in GPIO and trying to run the program without initialization of SMCLK to 16 MHz.
    I am newbie and trying different things, sorry for errors. Thank you for your answer
    Regards
    -Onkar
  • Your UCA0MCTLW register's UCBRSx bits are incorrect, it should be 0x2080.

    Regards,
    Ryan
  • I missed the detail.

    Thank you so much for your response and time. It means a lot.

    Regards
    Onkar

**Attention** This is a public forum