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
Post a Comment