Part Number: MSP430FR2311
I am having trouble with a simple UART echo wiring pins 1.6 and 1.7 together. I put this code together from various examples. When I step through the code, I can confirm that transmission is complete by the fact that the transmit interrupt is invoked (UCTXCPTIFG). When I configure the interrupt to be UCRXIFG and step through the code, the receive interrupt is never invoked. I am using CCS 9.0.1.00004 only. Here is my code:
#include <msp430.h> #include <stdint.h> #define ENABLE_PINS 0xFFFE // Required to use inputs and outputs /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR = BIT0; // Make P1.0 an output for red LED P1OUT = 0x00; // Red LED initially off // Configure UART pins P1SEL0 |= BIT6 | BIT7; // set 2-UART pin as second function // Unlock GPIO PM5CTL0 &= ~LOCKLPM5; // Configure one FRAM waitstate as required by the device datasheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. FRCTL0 = FRCTLPW | NWAITS_1; __bis_SR_register(SCG0); // disable FLL CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source CSCTL0 = 0; // clear DCO and MOD registers CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first CSCTL1 |= DCORSEL_5; // Set DCO = 16MHz CSCTL2 = FLLD_0 + 487; // set to fDCOCLKDIV = (FLLN + 1)*(fFLLREFCLK/n) // = (487 + 1)*(32.768 kHz/1) // = 16 MHz __delay_cycles(3); __bic_SR_register(SCG0); // enable FLL while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // FLL locked CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // Configure UART // From User's Guide Table of Baud Rates, 9600 baud at BRCLK = 16000000 // UCBRx = 104; // UCBRSx = 0xD6 // UCOS16 = 1 // UCBRFx = 2 // Fractional portion = 0.1667 // User's Guide Table 21-5: UCBRSx = 0xD6 // UCBRFx = 2 UCA0CTLW0 |= UCSWRST; UCA0CTLW0 |= UCSSEL__SMCLK; UCA0BRW = 104; UCA0MCTLW = 0xD600 | UCOS16_1 | UCBRF_2; UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI // Source = ACLK = 32768 Hz, divided by 16 (2048 Hz) SYSCFG2 |= RTCCKSEL; // Select ACLK as RTC clock RTCCTL = RTCSS_1 | RTCSR | RTCPS__16; UCA0IE = UCTXCPTIFG; // Interrupt when RX received UCA0TXBUF = 0x56; _BIS_SR(GIE); while (1); } #pragma vector=USCI_A0_VECTOR __interrupt void port1_ISR(void) { if(UCA0RXBUF > 0x25) { P1OUT = BIT0; // Turn on the red LED } else { P1OUT = 0x00; } UCA0IFG = UCA0IFG & (~UCTXCPTIFG); // Clear TX ComPleTe Interrupt FlaG UCA0TXBUF = 0x56; }