lib_uart uart_rx.xc bug?
Posted: Mon Aug 14, 2017 3:20 pm
Hi,
I found when I am inputting a break (i.e. uart input stuck at zero) with the uart_rx.xc the code outputs continuous 0x00 bytes, even though there is no stop bit -> start bit transition. I believe that is due to the INPUTTING_STOP_BIT state not functioning correctly. I think it may arise in situations where stop_bits is set to 1 (probably the most common situation I would imagine). Here is the existing code:
I have changed it as follows and it seems to work better (i.e. not returning continuous 0x00 bytes in stuck at zero line state but still returning expected data in normal line state):
I found when I am inputting a break (i.e. uart input stuck at zero) with the uart_rx.xc the code outputs continuous 0x00 bytes, even though there is no stop bit -> start bit transition. I believe that is due to the INPUTTING_STOP_BIT state not functioning correctly. I think it may arise in situations where stop_bits is set to 1 (probably the most common situation I would imagine). Here is the existing code:
Code: Select all
case INPUTTING_STOP_BIT:
int level_test = p_rxd.input();
if (level_test == 0) {
p_rxd.event_when_pins_eq(1);
state = WAITING_FOR_HIGH;
}
stop_bit_count--;
t += bit_time;
if (stop_bit_count == 0) {
p_rxd.event_when_pins_eq(0);
state = WAITING_FOR_INPUT;
}
break;
Code: Select all
case INPUTTING_STOP_BIT:
int level_test = p_rxd.input();
if (level_test == 0) {
p_rxd.event_when_pins_eq(1);
state = WAITING_FOR_HIGH;
}
else {
stop_bit_count--;
t += bit_time;
if (stop_bit_count == 0) {
p_rxd.event_when_pins_eq(0);
state = WAITING_FOR_INPUT;
}
}
break;