Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

Need help for my RS232 in NIOS II

Altera_Forum
Honored Contributor II
1,318 Views

Hi,  

 

I am doing a project with NIOS II and I need to transfer data between my board and the PC through the RS232. 

 

I generated a NIOS II system with RS232 support. On my test, I can transfer data from the FPGA board to PC through RS232 by using the "IOWR_ALTERA_AVALON_UART_TXDATA" macro, but I can't write data into the FPGA board through RS232.  

 

My question is: 

If I want to write data into the FPGA board through RS232, do I need to setup the RS232's control register as "0x0080" (RRDY) before the writing? Or I just need to check the status register's value and write data when it is "0x0080". Even easiler, I just need to use the "IOWR_ALTERA_AVALON_UART_RXDATA" to write data directly without checking or setting the status of RS232. 

 

Actually, I've tried all of the three above methods but failed. Everytime when I tried to read the data that I wrote in by using the "IORD_ALTERA_AVALON_UART_RXDATA", the value is "0". 

 

Could anyone help me? Thanks.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
547 Views

Hey, 

 

This is a function thats send one byte to the UART 

 

void UART1_T(unsigned char ch) 

while((IORD_ALTERA_AVALON_UART_STATUS(UART1_BASE) & 0x040) != 0x040){ ;} 

IOWR_ALTERA_AVALON_UART_TXDATA(UART1_BASE,ch); 

 

You only have to change UART1_BASE address to your UART address that you can find back in your system.h file 

 

Good luck 

Regards 

Karel
0 Kudos
Altera_Forum
Honored Contributor II
547 Views

 

--- Quote Start ---  

Hi,  

 

I am doing a project with NIOS II and I need to transfer data between my board and the PC through the RS232. 

 

I generated a NIOS II system with RS232 support. On my test, I can transfer data from the FPGA board to PC through RS232 by using the "IOWR_ALTERA_AVALON_UART_TXDATA" macro, but I can't write data into the FPGA board through RS232.  

 

My question is: 

If I want to write data into the FPGA board through RS232, do I need to setup the RS232's control register as "0x0080" (RRDY) before the writing? Or I just need to check the status register's value and write data when it is "0x0080". Even easiler, I just need to use the "IOWR_ALTERA_AVALON_UART_RXDATA" to write data directly without checking or setting the status of RS232. 

 

Actually, I've tried all of the three above methods but failed. Everytime when I tried to read the data that I wrote in by using the "IORD_ALTERA_AVALON_UART_RXDATA", the value is "0". 

 

Could anyone help me? Thanks. 

--- Quote End ---  

 

 

 

char character; 

while(1) 

alt_putstr("\nEnter character :\t"); 

character = alt_getchar(); 

alt_putstr("\nEchoed character :\t"); 

putchar(character); 

//UART1_T(c); 

return 0;
0 Kudos
Altera_Forum
Honored Contributor II
547 Views

1. > Add RS232 in SOPC 

2. > Open RS232 in Eclips "FILE *fp", fp = fopen("path of RS232 from system.h like /dev/....","rb+"); 

3. > use fprintf(fp,"%d", --your data---); for writing on RS232 port
0 Kudos
Reply