Altera_Forum
Honored Contributor
18 years agoDE2 -> NiosII UART (RS-232) problems
I am using the DE2 evaluation board for a project I am working on. I have just recently been learning this hardware and have upto now have been able to successfully use the LCD, sdram, swtiches and leds.
As I was hoping the UART for serial comm would be simple, I'm having trouble. I've correctly setup the NIOS 2 processor with the UART (rs-232) component on the avalon switch, and inserted RXD and TXD to my HDL file. Using the IDE, i wrote a sample program to send and receive data from my PC which is using Hyperterminal. The following is the code I use for my test: # include <stdio.h># include <string.h> int main{ FILE* fp; char prompt = 0; fp = fopen("/dev/uart", "r+"); if(fp){ printf("UART open. \n"); } else{ printf("UART closed. \n); } fprintf(fp, "UART\n"); while(prompt != 'v'){ prompt = getc(fp); printf("%c \n",prompt); } fclose(fp); return 0; } This program stays in the while loop foever, as it cannot read input from my terminal. Any ideas????