Part Number: MSP-EXP430FR5994
Other Parts Discussed in Thread: MSP430FR5994
As described with the MSP430FR5994 LaunchPad™ Development Kit User's Guide (SLAU678A) section 2.2.4, the Application UART is connected to the eUSCI_A0. The datasheet points out P2.0 and P2.1 as the pins for eUSCI_A0 transmit and receive.
I tried the register level peripheral example "eUSCI_A0 UART echo at 9600 baud using BRCLK = 8MHz" and modified the source to actually meet eUSCI_A0 (the example source code uses eUSCI_A3 actually).
However, I could not get the simple example to work...
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
// Configure GPIO
P2SEL1 &= ~(BIT0 | BIT1);
P2SEL0 |= (BIT0 | BIT1); // USCI_A0 UART operation
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Startup clock system with max DCO setting ~8MHz
CSCTL0_H = CSKEY_H; // Unlock CS registers
CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // Lock CS registers
// Configure USCI_A0 for UART mode
UCA0CTLW0 = UCSWRST; // Put eUSCI in reset
UCA0CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 21-4: UCBRSx = 0x04
// UCBRFx = int ( (52.083-52)*16) = 1
UCA0BRW = 52; // 8000000/16/9600
UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
UCA0TXBUF = 'r';
UCA0TXBUF = 'e';
UCA0TXBUF = 'a';
UCA0TXBUF = 'd';
UCA0TXBUF = 'y';
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
return 0;
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=EUSCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(EUSCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA0IFG&UCTXIFG));
UCA0TXBUF = UCA0RXBUF;
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}
What did I miss?