Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

[Q] Using Launchpad to use UART with 5xx MCU

$
0
0

I recently purchased a MSP430-T5510 board. It has RXD on P4.5 and TXD on P4.4, which has connection with pin 4 and 3 on the UEXT connector. I'm finding a way to use UART with this board since doing it via JTAG can't be done. With the following code:

int main(void) {
    //REFO for ACLK, source for FLL
    UCSCTL3 |= SELREF_2;
    UCSCTL4 |= SELA_2;
    //set DCO frequency at 16MHz, so MCLK runs at 8MHz
    UCSCTL2 |= 245;
  
    //UART  
    P4SEL |= BIT4 + BIT5;
    UCA0CTL1 |= UCSSEL_2;                   //SMCLK
    UCA0CTL0 &= ~UC7BIT;					//8-bit
    //http://www.daycounter.com/Calculators/MSP430-Uart-Calculator.phtml
    UCA0BR0 = 0x41;                         //8MHz 9600
    UCA0BR1 = 0x3;                          // 8MHz 9600
    UCA0MCTL = 0x92;                     
    UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

    __enable_interrupt();
    LPM0;
}

#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;
    }
}

I connected P4.5 to P1.1 of the Launchpad board (RXD) and P4.4 to P1.2 of the board (TXD), with the TX, RX headers on the Launchpad connected horizontally but nothing gets echoed back. What am I doing wrong?


Viewing all articles
Browse latest Browse all 2077

Trending Articles