Forum Discussion
Altera_Forum
Honored Contributor
21 years agoRead from UART
Good morning! I´m a NIOSII starter and trying to get first results. My question: Why can´t i read anything from the UART? I can write to it, but i don´t receive anything or i receive and don´t ...
Altera_Forum
Honored Contributor
21 years agodo you use a while(1) around read ???
you don't need an interrupt, this is always done in the HAL driver altera_avalon_uart.c I don`t know if this is necessary, but set stdin,stdout,stderr in syslib properties to null or something other than uart1. int main() { fdterm = open("/dev/uart1", O_RDWR | O_NONBLOCK | O_NOCTTY); fpterm = fdopen(fdterm,"rw+"); fprintf(fpterm,"UART1 STARTED\r\n"); // check initial output while(1) { uart1_rxcount=read(fdterm, &uart1_rxbuffer, sizeof(uart1_rxbuffer)); if(uart1_rxcount>0) { { fprintf(fpterm,"received:%s\r\n",uart1_rxbuffer); } } }