c - Stopping the program when reading data from UART -


i have simple code:

while(1){                char dolar = gps_get_char();//read char 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 interrupt         lcd ^= (1 << led_on_off);         tl2 = 0;     }    } 

but when gps turned off, program stops here:

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

where function gps_get_char();

char gps_get_char() {     unsigned int in = 0;      {         in = uart1_getc();     } while((in & uart_no_data) || (in & uart_buffer_overflow));      return((char) in); } 

any idea why program stopped?

even if current approach works, prone @ losing uart data. should using interrupts instead of polling. have interrupt fill sufficiently large buffer , set flag condition when done. then, have program process buffer.

cheers.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -