Part Number: MSP430FR2311
Hello,
I wana to blink led when char is received by RXBUF on RXPIN. Following code is not working.
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Configure GPIO
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate 1previously configured port settings
P1OUT &= ~BIT0 + BIT1; // P1.0 and P1.1 = 0
P1DIR |= BIT0 + BIT1; // P1.0 and P1.1 output
P1SEL0 |= BIT6 | BIT7; // set 2-UART pin as second function
// Configure UART
UCA0CTLW0 |= UCSWRST;
UCA0CTLW0 |= UCSSEL_1; // set ACLK as BRCLK
// Baud Rate calculation. Referred to UG 17.3.10
// (1) N=32768/4800=6.827
// (2) OS16=0, UCBRx=INT(N)=6
// (4) Fractional portion = 0.827. Refered to UG Table 17-4, UCBRSx=0xEE.
UCA0BR0 = 6; // INT(32768/4800)
UCA0BR1 = 0x00;
UCA0MCTLW = 0xEE00;
UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled
// __no_operation();
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA0IFG&UCRXIFG));
P1OUT ^= BIT0;
P1OUT ^= BIT1;
UCA0IE &= ~UCRXIE;
__no_operation();// Enable USCI_A0 RX interrupt
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}
Please do needful.