- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using a Fifoed UART for reading characters from the serial interface. I found that getchar() is blocking when no characters are present in the fifo which I cannot use. Is there a way to determine if there are characters present in the read fifo. I can use this signal then for reading them then with getchar(). Thank you all for your responses. Regards, WamorLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have just solved my problem. I have upgraded to FIFOed-UART version 13.1 which works fine for me now. Regards, Wamor
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page