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.

problem with interrupts

Altera_Forum
Honored Contributor II
1,401 Views

I have tried to make a simple interrupt of a push button and when i registered the ISR it immediately started to execute the ISR like it's an endless loop.:confused:  

 

Another thing, what is the difference between alt_irq_register() and alt_ic_isr_register()? 

(i have used alt_irq_register() ); 

 

can someone give me an example code for simple interrupt....? 

 

thanks!!!:rolleyes:
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
640 Views

it might be that you are not Resetting the Button's edge capture register. give "IOWR_ALTERA_AVALON_PIO_EDGE_CAP(<BASE ADDRESS OF YOUR BUTTON), 0); "  

where the ISR work ends
0 Kudos
Altera_Forum
Honored Contributor II
640 Views

I have an example (it works fine): 

# include "test_II.h"# define switches_base 0x00101030# define leds_base 0x00101000# define push_base 0x00101020 

 

 

// *** Maneja la interrupcion **** 

static void push_isr(void* context, alt_u32 id){ 

 

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

 

*function=IORD_ALTERA_AVALON_PIO_EDGE_CAP(push_base); 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(push_base,0); 

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(push_base,0xF);  

//************************************* 

 

 

int main(void) 

{ volatile int function=0; 

alt_u32 switches;  

 

// Activas la interrupcion. 

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(push_base,0xF); 

alt_irq_register(PUSH_IRQ,(void*)&function, push_isr); 

 

 

while(1){ 

switch(function){ 

case 0x1: 

switches= IORD_ALTERA_AVALON_PIO_DATA(switches_base); 

IOWR_ALTERA_AVALON_PIO_DATA(leds_base,switches);  

function=0; 

 

break;  

 

default: 

break; 

 

 

return 0; 

 

 

Maybe it could help you...
0 Kudos
Altera_Forum
Honored Contributor II
640 Views

thank you both! 

i think that i found the problem!! i have writen to the edge cupture register the value '1' insted of '0' and it suddenly works!! i dont know why, does someone has an explanation why?.. 

 

thanks for your help!!!
0 Kudos
Altera_Forum
Honored Contributor II
640 Views

Possibly, when the interrupt is level triggered, the 'button up' state is the one that was asserting the IRQ. (Even if it were the 'button down' state the ISR would be called repeatedly untill the button was released.)

0 Kudos
Altera_Forum
Honored Contributor II
640 Views

Bit n in the edgecapture register is set to 1 whenever an edge is detected on input 

port n. An Avalon-MM master peripheral can read the edgecapture register to 

determine if an edge has occurred on any of the PIO input ports. if the option enable 

bit-clearing for edge capture register is turned off, writing any value to the 

edgecapture register clears all bits in the register. otherwise, writing a 1 to a 

particular bit in the register clears only that bit.
0 Kudos
Reply