Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

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

Altera_Forum
Honored Contributor II
2,261 Views

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..??
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,285 Views

you can use a PIO component for that.

0 Kudos
Altera_Forum
Honored Contributor II
1,285 Views

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..??
0 Kudos
Altera_Forum
Honored Contributor II
1,285 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
1,285 Views

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..
0 Kudos
Altera_Forum
Honored Contributor II
1,285 Views

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 

}
0 Kudos
Reply