Forum Discussion

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

Sopc uart rs232

Hi all.

Does somebody have an example of how to use exactly this simple ip in a NIOS system ? or where to find one.....

I've tried the ip user manual example but without luck, I'm missing something, I'm sure... but, like I've not any example to look at......

Cheers, and thanks in advance.

Alberto.

8 Replies

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

    Hi Alberto,

    I don't know if a uart rs232 example is available; I've never seen one.

    Anyway, if you've already read the ip user guide, you may take a look to the device HAL driver in \ip\altera\sopc_builder_ip\altera_avalon_uart\HAL

    I think it is easy to integrate it in your application.

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

    Thank you Cris.

    I've tried again with the ip simple example and I get it work, maybe I will go for the HAL API code now.

    Regards.

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

    Hi,

    Please can you tell me how you processed to getting it done because I am trying it unsuccessfully since 2 weeks.

    I used the step by step example from the doc 351 (simulating nios ii embedded processordesigns) but I couldn't simulate it within Modelsim.

    Please any advice would be appreciate

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

    --- Quote Start ---

    Hi,

    Please can you tell me how you processed to getting it done because I am trying it unsuccessfully since 2 weeks.

    I used the step by step example from the doc 351 (simulating nios ii embedded processordesigns) but I couldn't simulate it within Modelsim.

    Please any advice would be appreciate

    Regards,

    --- Quote End ---

    Hi.

    I'm not simulating this, I'm running it in real word, and it works perfect, just the exactly code in the doc.

    Cheers.

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

    Hi,

    Please can you tell me which code do you means?

    I don't get it. I intend to test my uart. How should I start?

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

    This is a part of my test code.

    Cheers.

    Alberto.

    
     int count = 0;
     int largo_cadena = 0;
     char* msg = "Detected the character 't'.\n";
     FILE* fp;
     IOWR(RTS_BASE,0,1); //
     DEMO_PRINTF("In UART.\n");
     fp = fopen ("/dev/serial", "r+"); //Open file for reading and writing
        if (fp)
        {
        cursorX=0;
        cursorY=-1;
        DEMO_PRINTF("UART in ready.\n");
        IOWR(RTS_BASE,0,0); //
        largo_cadena = getc(fp);       // Get string size
        IOWR(RTS_BASE,0,1); //
        int prompt;
        while (1){
            for(i=0;i<largo_cadena;i++){
              prompt=32;
            }
            i=-1;
            while (1) //
            { // Loop until we receive a 'v'.
            IOWR(RTS_BASE,0,0); //
            prompt = getc(fp);  // Get a character from the UART. 
            IOWR(RTS_BASE,0,1); // 
            if (prompt == 13) {
                cursorY++;
                DEMO_PRINTF("Find a  Enter.\n");
            }
            if (prompt == 255) {
                break;
            }
            i++;
            DEMO_PRINTF("%c", prompt);
            }
         i=i-1;
         DEMO_PRINTF("Largo cadena: %d\n", largo_cadena);
         TMostrar_String(cursorX, cursorY, 0, 0, 0xFFFE, 0, prompt, largo_cadena-1, Fuente);
         usleep(500000);
        }
        DEMO_PRINTF("Out UART.\n");
        fprintf(fp, "Closing the UART file.\n");
        fclose (fp);
        }
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The UART example is complete, forget the cursorX, cursorY, RTS_BASE, etc.

    You shouldn't need more.