Forum Discussion

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

some queations about UART

[quote]

Hello!

When I use De2 board ,add a UART IP core in my cpu,I want to use a peripheral equipment connects to the serial port of De2.

First ,I use the serial port of De2 connectted to PC,I found there no problem,it can receive and send data. But when I use the serial port of De2 connectted to the peripheral equipment ,I can open the UART of DE2,but it can't receive the data from the peripheral equipment ,what's the problem? thank you!

(the peripheral equipment is scan equipment,it can connect with the De2 using a serial port .)

ps:

[CODE]

the code in Nios IDE is here:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include "system.h"

int main()

{int i=0;

int length=500;

char reply[500];

char c;

FILE *fp;

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

while(1)

{if (fp)

{printf("\nOpen Sucessfully!\n");

printf("\nReady to receive!\n");

fgets(reply,500,fp);

printf("haha\n");

for(i=0;i<length;i++)

{printf("%c",reply[i]);

}

}

}

fclose(fp);

return 0;

}

and stdout set is jtag_uart

stdin set is uart_0

stderr set is jtag_uart

No RepliesBe the first to reply