Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,617 Views

help on rs232 communication niosII

How do I get to communicate with the Nios II via serial pc? 

Basically I would like nios II sends a string to the serial port. 

 

I use The Nios® II Software Build Tools (SBT) for eclipse.  

 

I wrote the following code: 

# include<stdio.h> 

int main(){ 

printf("Hello world"); 

 

and then I tried to change the standard input and output to UART1 standart but nothing is written to the serial. 

 

 

you could tell me some tutorials on the serial communication between the PC and nios II? 

 

 

thanks in advance for help
0 Kudos
13 Replies
Altera_Forum
Honored Contributor I
79 Views

First Add the RS232 on system using SOPC  

 

Then Open RS232 Port on Eclips. 

 

then use std. fprintf for sending the data on RS232
Altera_Forum
Honored Contributor I
79 Views

kaushal's answer is right, you do it in according with his answer.

Altera_Forum
Honored Contributor I
79 Views

I added the RS232 on system using SOPC. 

 

How to open RS232 Port on eclipse? If I use jtaguart as stdin and stdout the code works but if I use RS232 don't work.... 

 

Thanks in advance for help
Altera_Forum
Honored Contributor I
79 Views

 

--- Quote Start ---  

I added the RS232 on system using SOPC. 

 

How to open RS232 Port on eclipse? If I use jtaguart as stdin and stdout the code works but if I use RS232 don't work.... 

 

Thanks in advance for help 

--- Quote End ---  

 

write down below code in your main file. 

 

 

 

FILE *fp; 

 

fp = fopen("----copy past path of your RS232 file from system .h-----","rb"); 

if(fp==NULL) 

printf("\nFile /RS232 not open for writing...."); 

 

else 

 

fprintf(fp,"%d",---data (int)which you want to write on RS232---); 

 

 

fclose(fp);
Altera_Forum
Honored Contributor I
79 Views

Solved thanks.

Altera_Forum
Honored Contributor I
79 Views

Could you post what you did to solve the problem in case others have the same issue?

Altera_Forum
Honored Contributor I
79 Views

I solved it using the code posted by Kaushal. I was wrong path of my RS232 file from system .h ...  

 

I opened the file system.h, and I put the right path.  

 

Note: if you use a serial sniffer like Hyperterminal you check that you have it set up correctly.. 

 

Sorry for my english but I am Italian if there are any problems please do not hesitate to ask. :D
Altera_Forum
Honored Contributor I
79 Views

fopen("/dev/uart/","w") returns NULL for me, do you know what could fix this?

Altera_Forum
Honored Contributor I
79 Views

 

--- Quote Start ---  

fopen("/dev/uart/","w") returns NULL for me, do you know what could fix this? 

--- Quote End ---  

 

go to the system.h and find out the exact path for rs232 and then use that path for fopen
Altera_Forum
Honored Contributor I
79 Views

Hi there. 

I'm new with Nios SBT for Eclipse and I'm facing a problem with the rs232. 

Just like ermanno.tedeschi, I need to use the serial port but, despite I have added the RS232 on my system using SOPC, I cannot make the 'fopen' and the 'fclose' commands works... 

Does anybody has some tip/hint...something to tell me? 

 

Cheers
Altera_Forum
Honored Contributor I
79 Views

make sure you have add the correct header files ....for fopen and fclose

Altera_Forum
Honored Contributor I
79 Views

Hi guy, 

I figured out what was wrong with the project. 

Firstly, I setted up the wrong pins on quartus. 

Then, instead of using 'fopen' and 'fclose' commands, I used "IOWR_ALTERA_AVALON_UART_RXDATA(UART_0_BASE, (data-to-be-send))". 

It worked!
Altera_Forum
Honored Contributor I
79 Views

I am Italian let me know what is your problem.

Reply