Part Number: MSP430F6459
Hi,
I am writing a simple application where the controller should receive the character through UART interrupt and meanwhile my while loop should run indepedently.
The below is code I am trying to do where UART should accept the character and my while loop should run continuously and should execute the if or else if condition based on the character received.
But it is not working in that way, it is stopping at __bis_SR_register(LPM0_bits + GIE); and not even entering into the while loop.
Can anyone please help me to solve this issue.
void main(void)
{
__bis_SR_register(LPM0_bits + GIE);
while(1)
{
if(UartRx_flag == 1)
{
UartRx_flag = 0;
if(UCA0RXBUF == 0x31)
{
__delay_cycles(100000);
ReadLocalTemp();
TestMenu();
}
else if(UCA0RXBUF == 0x32)
{
__delay_cycles(100000);
ReadRemoteTemp();
TestMenu();
}
}
}
}
//******************************************************************************
// UART RX Interrupt ***********************************************************
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
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
UartRx_flag = 1; // Making flag high
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
Thanks & Regards,
K. Aravind,
Sigma Advanced Systems,
9848992750.