Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
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.
21615 Discussions

pio interrupt not working

Altera_Forum
Honored Contributor II
2,923 Views

Hii , 

 

I'm new to the nios. 

i have a push button in my project which is connected to the pio ,which shouid generate interrupt whenever its get pressed. 

its falling edge irq. 

but interrupt is not getting generated. 

 

code is as bellow:# for initialization 

 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(START_STOP_KEY_BASE, 0x0); 

alt_ic_isr_register(START_STOP_KEY_IRQ_INTERRUPT_CONTROLLER_ID , START_STOP_KEY_IRQ, Status_chng, NULL, 0x0); 

 

# ISR 

 

 

inChL = IORD_ALTERA_AVALON_PIO_EDGE_CAP(START_STOP_KEY_BASE); 

 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(START_STOP_KEY_BASE, 0x0); 

IORD_ALTERA_AVALON_PIO_EDGE_CAP(START_STOP_KEY_BASE); 

 

 

 

edge cap read is always high . 

 

i tried enabling irq with hal function also but no result . 

 

controller is not going to isr at all. 

What m i missing here or if someone have some sample code of pio interrupt based on edge plz share... 

 

 

Thanks and regards  

Ankur
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,789 Views

Have you checked the PIO settings in the SOPC builder/Qsys? 

this example is from the Nios II software developers handbook 

Example 8–1. An ISR to Service a Button PIO Interrupt 

# include "system.h" 

# include "altera_avalon_pio_regs.h" 

# include "alt_types.h" 

# ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT 

static void handle_button_interrupts(void* context) 

# else 

static void handle_button_interrupts(void* context, alt_u32 id) 

# endif 

/* Cast context to edge_capture's type. It is important that this 

be declared volatile to avoid unwanted compiler optimization. */ 

volatile int* edge_capture_ptr = (volatile int*) context; 

/* 

* Read the edge capture register on the button PIO. 

* Store value. 

*/ 

*edge_capture_ptr = 

IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE); 

/* Write to the edge capture register to reset it. */ 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0); 

/* Read the PIO to delay ISR exit. This is done to prevent a 

spurious interrupt in systems with high processor -> pio 

latency and fast interrupts. */ 

IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
0 Kudos
Altera_Forum
Honored Contributor II
1,789 Views

Hello Ulika, 

 

Thanks for your reply. 

 

pio setting looks good. 

and i have tried with this example but still its not working....
0 Kudos
Altera_Forum
Honored Contributor II
1,789 Views

sry uilka*

0 Kudos
Reply