Part Number: MSP430F149
hi, i need your help, now i'm working on msp430f149 project, and my msp430f149 will connect another device via UART, what i want to do is LCD displays "please connect device firstly" if the device did not connect when msp430f149 send data via UART. i used a timer to check, if UART device has not response in 5s, timer will set a flag, and msp430f149 will quit UART process and display "please connect device firstly", but right now, the UART process always hang on if the device did not connect. my code as below.
#pragma vector=TIMERB1_VECTOR
__interrupt void Timer_B1 (void)
{
switch(__even_in_range(TBIV,2))
{
case 2:
{
uarterror=1;
TBCCTL1 &= ~CCIE;
break;
}
default: break;
}
}
void rs232_fn(uchar command,uchar length,uchar *ptr)
{
uchar i,temp,checksum;
//5S waiting for UART response
TBCTL |= TBCLR;
TBCTL = TBSSEL_1 + ID_3 + MC_1; //clock from ACLK, and devided by 8, 32.768khz/8=4096Hz,
TBCCTL1 = CCIE;
IE1 &= ~URXIE0; //disable Rx interrupt
while((IFG1&UTXIFG0)==0)
{
if(uarterror)
break;
}
if(uarterror)
{
uarterror=0;
IE1|=URXIE0;
page =200;
DisplayDesk(page); //display "please connect device firstly"
}
else
{
...
}
}