Forum Discussion
Altera_Forum
Honored Contributor
20 years agoFIFOed Avalon Uart
I have posted the FIFOed avalon UART in the Hardware Projects area. It is the standard UART that comes with Nios but it has additional features such as FIFOs and hardware CTS fifoed avalon uar...
Altera_Forum
Honored Contributor
14 years agoThere is an error in the fifoed_avalon_uart.c file (both 9.1 & 9.3 versions). When using as ALT_USE_SMALL_DRIVERS or FIFOED_AVALON_UART_SMALL (non-interrupt mode), the read routine doesn't work if requesting more than 1 byte, in fact it fails to get any bytes at all. I am attaching the changes I made to make it work. There were no tests for errors in status and I have not added any here. The only changes are in the "fifoed_avalon_uart_read" function. The changes have been tested and are working here. The uarts are being used here with 1K read and 1K write fifos at 1M baud in the FIFOED_AVALON_UART_SMALL mode. At this speed interrupts are not used as they interfere with operation.</SPAN>
int fifoed_avalon_uart_read (fifoed_avalon_uart_state* sp, char* ptr, int len, int flags) { int block; int i; block = !(flags & O_NONBLOCK); i = 0; do { while((IORD_FIFOED_AVALON_UART_STATUS(sp->base) & FIFOED_AVALON_UART_CONTROL_RRDY_MSK) && (i < len)) { IOWR_FIFOED_AVALON_UART_STATUS(sp->base, 0); // clear any error flags ptr[i++] = IORD_FIFOED_AVALON_UART_RXDATA(sp->base); // get data } if( i > 0) // if anything there, return it return i; } while(block); ALT_ERRNO = EWOULDBLOCK; return 0; }