Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

using altera_up_avalon_rs232.h to set up rs232 communication

Altera_Forum
Honored Contributor II
2,359 Views

Hello. 

 

I've found this header file and I have been trying to use it to communicate back and forth between a PC and my development board, Altera DE1. To use functions that read and write characters, I need two variables: the character that I am reading/sending and something called alt_up_rs232_dev which is a 'RS232 device structure'. Here is the prototype of the function that sends a character: 

 

int alt_up_rs232_write_data(alt_up_rs232_dev *rs232, alt_u8 data); 

 

Could you be so kind to tell me what a 'RS232 device structure' actually is? What is it that the functions expect? 

 

Thank you.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
1,499 Views

Hello, me again. 

 

I just figured out there is a function called: 

 

alt_up_rs232_dev* alt_up_rs232_open_dev(const char *name) 

 

which does exactly what I asked here - it returns the pointer to a RS232 device structure. 

 

My problem now is the parameter name of the 'open' function. My uart module in the SOPC builder is called uart_0, but when I run this function after pointing *name to 'uart_0' I get error. 

 

Does anybody maybe have a working example of these functions?  

 

Thank you. 

0 Kudos
Altera_Forum
Honored Contributor II
1,499 Views

I think the name will be "/dev/uart_0". Have a look at the generated system.h file, it should be somewhere in the uart_0 section, probably in a# define UART_0_NAME

0 Kudos
Altera_Forum
Honored Contributor II
1,499 Views

Thank you. 

 

You were right - the correct name is: "/dev/uart_0". 

 

I changed this but I am having another problem. Please refer to a picture attached. As you can see, the code is quite simple. All I am trying to do is to send a data character ('A') over a rs232 port. But, Eclipse gives me two errors of unknown origin (points to 'line 0' of the .c file (?!)) and one that does not make any sense. The third does not make any sense because when I right-click on the function 'write_data' and then go 'Open declaration', it shows me that it knows where it is (you can see that on top tab). 

 

What could I do with these messages? 

 

Is there an easier way to use serial port on Altera DE1? 

 

Thank you.
0 Kudos
Altera_Forum
Honored Contributor II
1,499 Views

I don't know about those rs232 specific functions, but the driver should be integrated in the general HAL and you should be able to use standard input/output functions to read and write to the serial port instead of those functions. 

Have a look at this document (http://www.altera.com/literature/hb/nios2/n2sw_nii52004.pdf) to learn about the HAL, and especially the section about character mode devices, pages 6-8 and over.
0 Kudos
Reply