Forum Discussion

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

dev/uart_rs232

Hello!

I try to send data to the rs232 of the Nios Embedded Evaluation kit.

I used the SOPC Builder and used the SOPC files of the Nios II System Architect Design Tutorial. There I put in the uart-rs232.(9600 Baud one stop Bit) In the top level Design I put an input on the rxd_to_the_uart_rs232 (default value VCC) and an output on the txd_from_the_uart_rs232.

In Pin Setup I did this settings:

Node Name: Direction: Location: I/O Bank: VREF Group: I/OStandard:

rxd_to_the_uart_rs232 input IOBANK_8 8 - 2.5 V(default)

txd_from_the_uart_rs232 output IOBANK_8 8 - 2.5 V(default)

In Nios II IDE I compiled everything. The rs232 name: UART_RS232_NAME "/dev/uart_rs232"

The program to send data is this:

FILE *fp;

fp = fopen("/dev/uart_rs232", "w+"); // also used wb+, w+

if(fp){

printf("open succesful\n");

fwrite('a', sizeof('a'), 1, fp); // also used fwrite('a', strlen('a'), 1, fp);

fclose(fp);

}

else{

printf("Error writing rs232");

fclose(fp);

}

The file opens but I get no data out of the txd pin and I am sure I am using the right pin.

What am I doing wrong? Please help!!

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Sorry, I didn`t read your mail till now.

    I forgot to tell you that if you configure "active parallel" and "remote" you must include a 'Remote update 'module on your nios (SOPC Builder).(Peripherals->FPGA peripherals, connected via Avalon to the cpu). It works ok downloading .sof file via jtag. I don't know if other configuration modes work ok.

    As I said I don`t know of this is necesary but i configured this way. Perhaps only configuring dual-ports is enough.

    I think the examples given with the NEEK have this remote configuration.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello Ealonso!

    I have made all. Compilation was succesfull!

    But in Nios there are still no signals out of the rs232. If I put the stdout to the uart_rs232, I can`t run the program because it says : can't open uart : No such file or directory.

    It's so hopeless, everytime I get a bit forward nothing still happens!

    Do you have a running system that you can send me per mail, so that I can look where my faults are?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think that if you use a component as stdout, it isn't available for access through fopen() anymore.

    If you put stdout to the UART, then you can directly call printf() without opening any file, and the output should go to the UART.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Also tried this..

    Nothing, I think I am on the right way, but somewhere is a bug and I don't find it!

    I think it is still in my hardware. Has nobody a working SOPC and FPGA Project that I can implement with my Nios Software?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I got it ;-)

    All setups you told me were right and necessary Ealonso.

    The fault was that I wanted to take signals from the TXD. ;-D

    Thanks a lot for help!!