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.

CC430F137 with UART connection

Hi All,

I’m working with the CC430F137 chip.

While it’s P1.7 and P1.6 are connected to a UART source of 4800 I’ve configured the program as follows:

int main(void)

{

  i = 0;

  P1DIR |= BIT6;                            // Set P1.6 as TX output

  P1SEL |= BIT6 + BIT7;                     // Select P1.6 & P1.7 to UART function

 

  while (1)

  {

    UART_function ();

    if (i >= 199)

      break;

  }

}

 

void UART_function (void)

{

WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

 

  PMAPPWD = 0x02D52;                        // Get write-access to port mapping regs 

  P1MAP6 = PM_UCA0TXD;                      // Map UCA0TXD output to P1.6

  P1MAP7 = PM_UCA0RXD;                      // Map UCA0RXD output to P1.7

  PMAPPWD = 0;                              // Lock port mapping registers

 

  P1DIR |= BIT6;                            // Set P1.6 as TX output

  P1SEL |= BIT6 + BIT7;                     // Select P1.6 & P1.7 to UART function

 

  *pNMEA_Buffer = UCA0RXBUF;                // Read the info

  pNMEA_Buffer++;                           // update the address

 

  UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**

  UCA0CTL1 |= UCSSEL_1;                     // CLK = ACLK

  UCA0BR0 = 0x06;                           // 4800

  UCA0BR1 = 0x00;                           //

  UCA0MCTL |= UCBRS_7+UCBRF_0;              // Modulation UCBRSx=6, UCBRFx=0

  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

  UCA0IE |= UCRXIE;                         // Enable USCI_A1 RX interrupt

 }

// Echo back RXed character, confirm TX buffer is ready first

#pragma vector=USCI_A0_VECTOR

__interrupt void USCI_A0_ISR(void)

{

  switch(__even_in_range(UCA0IV,4))

  {

  case 0:break;                             // Vector 0 - no interrupt

  case 2:                                   // Vector 2 - RXIFG

    while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?

    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character

    break;

  case 4:break;                             // Vector 4 - TXIFG

  default: break;

  }

}

But it seems that I can’t read the correct baud rate (i.e. 4800).

Can someone check my 4800 configuration?

 

Thanks,

Shimo

**Attention** This is a public forum