Forum Discussion

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

Write in I/O ports

Hello, I want to write from my aplication in eCos only a bit, or led in the I/O ports in Nios II for mesure the timing latency. Can someone help me please? I don't know do this, and I don't find any documentation about.

Thanks, Guillem

1 Reply

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

    For my test I use :

    # include <cyg/hal/io.h>

    unsigned char ledpio;

    myfunct() {

    IOWR(LED_PIO_BASE,0, 1); // 1 for bit 0

    .................

    IOWR(LED_PIO_BASE,0, 0);

    // or

    ledpio = ledpio|4; // 4 for bit 2

    IOWR_8DIRECT(LED_PIO_BASE , 0, ledpio);

    ..............

    ledpio = ledpio&~4;

    IOWR_8DIRECT(LED_PIO_BASE , 0, ledpio);

    }

    LED_PIO_BASE is defined in cyg/hal/system.h for my project