Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

a strange appearance of UART

This is the uart programme in NIOSII IDE Technical Documentation

The output shows in console(see below),but I think it should be shown in seriel port debugger, I try changing property in 'RUN' option ,but cannot make it.

I tried one day :( ,

I hope someone can help me ,thanks !!

# include <stdio.h># include <string.h>

# include <system.h>

int main()

{

char *msg="detected character&#39;t&#39;.\n";

FILE *fp;

char prompt=0;

printf("please enter characters:\n");

fp=fopen("/dev/uart","r+");

if(fp)

{

while(prompt!=&#39;v&#39;)

{ prompt=getc(fp);

if(prompt==&#39;t&#39;)

{

fwrite(msg,strlen(msg),1,fp);

}

if(ferror(fp))

clearerr(fp);

}

fprintf(fp,"closing uart file handle.\n");

fclose(fp);

}

else

{

printf("fail to open file\n");

}

return 0;

}

It is right which the console shows:

nios2-terminal: connected to hardware target using UART on /dev/com1 at 9600 bau

d

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)

please enter characters:

abct

abcv

closing uart file handle.

BUT I DONNOT KNOW WHY IT SHOWS THERE ,only I KNOW when use JTAG_UART,It will show below console???
No RepliesBe the first to reply