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.

MSP430G2553: EMULATION EXP HW uart baud rate inconsistent.

Part Number: MSP430G2553
Other Parts Discussed in Thread: MSP430G2533

Tool/software:

#include <msp430.h>
#include <intrinsics.h>

#if defined(__IAR_SYSTEMS_ICC__)
int16_t __low_level_init(void) {
    // Stop WDT (Watch Dog Timer)
    WDTCTL = WDTPW + WDTHOLD;
    return(1);
}

#endif

#define LED BIT0
#define RXD BIT1
#define TXD BIT2

void initGPIO() {
    P1OUT &= ~LED;                 // Clear LED output
    P1DIR |= LED;                  // Set P1.0 as output

    P1SEL = BIT1 + BIT2;            // P1.1 = RX, P1.2 = TX
    P1SEL2 = BIT1 + BIT2;           // P1.1 = RX, P1.2 = TX
}

void initUART() {
    UCA0CTL1 |= UCSSEL_2;          // SMCLK
    UCA0BR0 = 104;                 // 1MHz 9600
    UCA0BR1 = 0;                   // 1MHz 9600
    UCA0MCTL = UCBRS0;             // Modulation UCBRSx = 1
    UCA0CTL1 &= ~UCSWRST;          // Initialize USCI state machine
}

void initWatchdog() {
    WDTCTL = WDT_MRST_32;          // Watchdog timer +/-32ms with SMCLK/32768
    // IE1 |= WDTIE;                  // Enable WDT interrupt
}


void initClock() {
    if (CALBC1_1MHZ==0xFF)         // If calibration constant erased
    {
        while(1);                  // do not load, trap CPU!!
    }
    //DCOCTL = 0;                    // Select lowest DCOx and MODx settings
    //BCSCTL1 = CALBC1_1MHZ;         // Set DCO
    //DCOCTL = CALDCO_1MHZ;

    BCSCTL1 = CALBC1_1MHZ;                    // Set range
    DCOCTL = CALDCO_1MHZ;
    BCSCTL2 &= ~(DIVS_3);                     // SMCLK = DCO = 1MHz
}// Clock calbirated at 1 MHz

void sendUART(char *text) {
    unsigned int i = 0;
    while(text[i] != '\0') {
        while (!(IFG2 & UCA0TXIFG)); // Wait for TX buffer to be ready
        UCA0TXBUF = text[i];
        i++;
    }
}

// Watchdog Timer interrupt service routine
int timerA_counter=0; 

#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void) {
    timerA_counter++;
}

void initTimerA(void) {
    TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, up mode, input divider = 8
    TACCR0 = (unsigned int)(125000 - 1);           // Count up to 125000 (1-second interval with 1 MHz SMCLK/8)
    TACCTL0 = CCIE;                // Enable interrupt for CCR0
}

int main(void) {
    WDTCTL = WDTPW + WDTHOLD;      // Stop watchdog timer
    initClock();                   // Setup clock
    initGPIO();                    // Initialize GPIO
    initUART();                    // Initialize UART
    initTimerA();                  // Initialize Timer A
    initWatchdog();                // Initialize watchdog timer

    // __bis_SR_register(GIE);        // Enable global interrupts
    _enable_interrupts();
    char out_string[] = "Hello World\n";
    // sendUART(out_string);
    while (1) {
        __no_operation();          // For debugger
        if (timerA_counter > 1)
        {
                P1OUT ^= LED;               // Toggle LED
                sendUART(out_string);
                timerA_counter = 0; 
        }
        WDTCTL = WDTPW | WDTCNTCL; // Kick the watchdog        
    }
}

I wrote the simplest code I can imagine in oder to print periodically "Hello world" over the HW uart. 

I'd expect a baudrate of 9600bps, but teraterm displays data only when configured at 2400bps, but  I can't figure out why. 

Any hint on this?

I am on theia, hence the firs #ifdef does not apply. 

**Attention** This is a public forum