You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing some code in assembly and was looking at the neorv32_uart.c file for "inspiration" on how to interface to the UART. And, saw this C function:
/**********************************************************************//** * Check if UART0 has received a char. * * @note This function is non-blocking. * @note Use neorv32_uart0_char_received_get(void) to get the char. * * @return =!0 when a char has been received. **************************************************************************/intneorv32_uart0_char_received(void) {
if ((NEORV32_UART0.DATA& (1<<UART_DATA_AVAIL)) !=0) {
return1;
}
else {
return0;
}
}
Although I did not test this, it seems wrong to me. If there are more than one chars in the UART RX FIFO, wouldn't neorv32_uart0_char_received() consume the first char (when checking the UART_DATA_AVAIL bit) in the FIFO and a later call to neorv32_uart0_char_received_get() would return the next char in the RX FIFO? (i.e., you would drop the first char).
When I coded this in assembly, I checked the UART_CTRL_RX_EMPTY bit in the NEORV32_UART0_CTRL control/status register instead -- it worked as expected.
Maybe, I'm missing something in the C code??
Thanks,
Brian
The text was updated successfully, but these errors were encountered:
I'm writing some code in assembly and was looking at the neorv32_uart.c file for "inspiration" on how to interface to the UART. And, saw this C function:
Although I did not test this, it seems wrong to me. If there are more than one chars in the UART RX FIFO, wouldn't
neorv32_uart0_char_received()
consume the first char (when checking theUART_DATA_AVAIL
bit) in the FIFO and a later call toneorv32_uart0_char_received_get()
would return the next char in the RX FIFO? (i.e., you would drop the first char).When I coded this in assembly, I checked the
UART_CTRL_RX_EMPTY
bit in theNEORV32_UART0_CTRL
control/status register instead -- it worked as expected.Maybe, I'm missing something in the C code??
Thanks,
Brian
The text was updated successfully, but these errors were encountered: