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.

understanding UCA0MCTL in msp430

Other Parts Discussed in Thread: MSP430G2553

hai,

      i am using msp430g2553 to send data in UART mode..the datasheet gives the calculated values of the UCABR AND UCBRSx...I M USING THE FOLLOWING CODE

void main(void)

{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = 'z';
}

i understood how the UCA0BR0 and UCA0BR1 values are calculated...but couldnt understand how the UCA0MCTL is configured based on baud rate and clock frequency..need help from you all..

thanks

senthil 

  • One great resource is
    http://processors.wiki.ti.com/index.php/Getting_Started_with_the_MSP430G2553_Value-Line_LaunchPad_Workshop
    Specifically, look at the chapter on serial communications.
    Hopefully, that helps.
  • hai todd,
    thanks for your information..will check it out...

    regads,
    senthil
  • The chapter ‘UART baud rate generation’ in the users guide tells you how the modulation is used.
    Basically, if you don’t have an integer factor between baudrate and clock, you’ll have a fraction left when setting UCBR. In standard mode (not oversampling), the UCBRSx bits are compensating for n/8 fractional remainder. So if clock/baudrate gives you e.g. 9.25, then this is 9+2/8 and UCBRSx must be set to 2.
    As a result, the baudrate generator will set the actual divider to UCBR+1 (=10) twice for each 8 bits, based on an internal pattern, giving an average of 9.25

**Attention** This is a public forum