Hello,
When I run the below code and type some characters the first line its reports the number of characters in the fifo and than reports that there are zero characters in the buffer.
This seems strange to me because I am not reading any characters from the buffer.
while ( true )
{
IOWR_ALTERA_AVALON_TIMER_SNAPH(TIMER_0_BASE, 0);
if ( IORD_ALTERA_AVALON_TIMER_SNAPH(TIMER_0_BASE) == 0 ) // timer overflow
{
words_in_fifo = IORD_FIFOED_AVALON_UART_RX_FIFO_USED( FIFOED_AVALON_UART_0_BASE );
printf("\r\n%i words in fifo, getting character\r\n", words_in_fifo );
IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_0_BASE, 0);
IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_0_BASE, 5000);
IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 0x04);
putchar( XMODEM_RWC ); // send "C"
count++;
IOWR_ALTERA_AVALON_PIO_DATA(PIO_OUTPUT_BASE, IORD_ALTERA_AVALON_PIO_DATA(PIO_OUTPUT_BASE) ^ DEBUG_LED1); // toggle LED
}
}
Anybody with some ideas what is wrong here.
I want to break out of the while-loop when a certain character is received without a blocking getchar().
Thank you,
Wamor