从UART读取数据时停止程序

时间:2015-04-29 12:19:14

标签: c avr uart

我有这个简单的代码:

while(1){           
    char dolar = gps_get_char();//read char from uart
    if ((dolar == '$') || (receive_dolar == 1)){
        receive_dolar = 1;

        gps_get_nmea(nmea_in, sizeof(nmea_in));
        rozloz_nmea();

        receive_dolar = 0;
    }       

    /*control running program*/
    if (tl2 == 1){ //flag button from interrupt
        LCD ^= (1 << LED_ON_OFF);
        tl2 = 0;
    }   
}

但是当GPS关闭时,程序停在此处:

char dolar = gps_get_char();//read char from uart

其中函数gps_get_char();

char gps_get_char()
{
    unsigned int in = 0;

    do {
        in = uart1_getc();
    } while((in & UART_NO_DATA) || (in & UART_BUFFER_OVERFLOW));

    return((char) in);
}

知道程序停止的原因吗?

0 个答案:

没有答案