I am using MSP430 Launchpad and trying to implement an simple ECHO program using UART interface. The Rx interrupt does not work. So the program does not work. Can you please highlight the problem in the code below?
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4SEL = BIT4+BIT5; // P4.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 6; // 1MHz 9600 (see User's Guide)
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL = UCBRS_0 + UCBRF_13 + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE | UCTXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
while (1)
;
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(UCA1IV)
{
case 0:break; // Vector 0 - no interrupt
case 2:
while (!(UCA1IFG&UCTXIFG)); // Vector 2 - RXIFG
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
break;
case 4:
break; // Vector 4 - TXIFG
default: break;
}
}
