Forum Discussion
Altera_Forum
Honored Contributor
19 years ago --- Quote Start --- originally posted by jakobjones@Feb 15 2007, 10:00 PM i realize that this post is old and you probably already found a solution but here you go anyway:
# include "altera_avalon_uart_regs.h"
char ch;
ch = iord_altera_avalon_uart_rxdata(uart1_base);
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=21653)
--- quote end ---
--- Quote End --- -- What if you are polling for a UART character? That command will just dump whatever's in the register, regardless of whether there's something there. I tried using this before reading the post, and I just get into a massive loop because there is no event that the code waits for. I believe that you need to look at RRDY in the _STATUS register (bit mask 0x0080) to see if there's a byte there. I have been trying this, but I'm getting "blank" data back. I believe that it's because I'm also using printf() HAL functions, which the datasheet refers to there being a problem running both register access and HAL at the same time. I'm having issues with a "small" build, and the getchar() and file i/o methods seem to work fine, but don't compile properly when targeting a device that does not have enough room to cram a "full" C library (EP2S15). Does anyone have a solution for polling for a UART character w/out getchar() or getc()? I suspect that I could stop using fprint() - HAL, and do all of the character I/O using IOWR_ALTERA_AVALON_UART_TXDATA(UART_0_BASE, data) commands, but rewriting fprint() is not too appealing, since I'm a hardware/FPGA guy that's dabbling in C. Any thoughts/comments on this would be appreciated. Thanks, Jeff