Forum Discussion

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

HOW TO DETECT A RISING EDGE(OF A PULSE) ON NIOS 2 (ucLINUX) AS AN INTERRUPT

hi every one,

i am using a nios 2(on cyclone 2) on uclinux os..can anybody suggest me ,how can i detect a rising or falling edge of a pulse(hardware signal) as an interrupt to the processor..??

5 Replies

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

    thanks for reply...

    den is it required to keep on polling a perticular PIO pin using readh(0x40008df)memory loc..? how can i read it as an interrupt..??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Double click on it in SOPC builder. Then you can have it trigger an interrupt on level change.

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

    but how will i come to know while executing my source code(in C) on processor..

    i.e when i detect the signal, i should go to some routine(signal handler) in my C code..

    what is the code sequence to do tat in c..
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    in the code there r instructions like

    main()

    {

    signal(SIGPIPE,SIG_IGN);

    int fp,oflags;

    signal(SIGIO, interrupt_handler);

    fp = open("/dev/interrupt1", O_NOCTTY);

    if(fp < 0)

    {

    printf("Error opening device node !\n");

    }

    else

    {

    fcntl(fp, F_SETOWN, getpid());

    oflags = fcntl(fp, F_GETFL);

    fcntl(fp, F_SETFL, oflags | FASYNC);

    }

    }///end of main function

    interrupt_handler()

    {

    \\control should come here when edge is detected

    }