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++
12606 Discussions

pushbutton interrup for ALTERA cyclonIII development board

Altera_Forum
Honored Contributor II
955 Views

pushbutton interrupts don´t work 

 

My Quartus project is a download from http://www.nioswiki.com/exampledesigns/nio...20designexample (http://www.nioswiki.com/exampledesigns/niosii3c120designexample)  

20090508a nios2 linux 3c120 125mhz.tar.gz was unpacked (I am not running linux though but uC-OSII with tools on Windows XP) 

My ALTERA Cyclone III Development Board be seen at http://www.altera.com/products/devkits/altera/kit-cyc3.html (http://www.altera.com/products/devkits/altera/kit-cyc3.html

 

I previously worked on the NEEK board and had the button interrupt working fine there for that board. I ported the code to My new project running on the Cyclone III Development Board and looked up the corresponding definitions in system.h  

 

My code now looks like this : 

 

#define  BSP_BUTTON_ADDR        USER_PB_PIO_4IN_BASE volatile INT32S      edge_capture;      /* A variable to hold the value of the button pio edge capture register. */ void BSP_HandleButtonInterrupts(void* context, INT32U ID) {     volatile int* edge_capture_ptr = (volatile int*) context;     // Store the value in the Button's edge capture register in *context.     *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BSP_BUTTON_ADDR);          switch(edge_capture) {            case 0x01:                registerPushButton(PUSHBUTTON_LEFT);                break;                       case 0x02:                registerPushButton(PUSHBUTTON_RIGHT);                break;                           case 0x04:                 registerPushButton(PUSHBUTTON_UP);                break;                           case 0x08:                 registerPushButton(PUSHBUTTON_DOWN);                break;                           default:               break;     }     // Reset the Button's edge capture register.     IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BSP_BUTTON_ADDR, 0); } void BSP_InitPushButtons(void) {     // Recast the edge_capture pointer to match the alt_irq_register() function     // prototype.     void* edge_capture_ptr = (void*) &edge_capture;     // Enable all 4 button interrupts.     IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BSP_BUTTON_ADDR, 0xf);     // Reset the edge capture register.     IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BSP_BUTTON_ADDR, 0x0);     // Register the interrupt handler.     alt_irq_register(USER_PB_PIO_4IN_IRQ, edge_capture_ptr, BSP_HandleButtonInterrupts ); } 

 

When I run the code It seems I get BSP_HandleButtonInterrupts() called continuously making the rest of the code freeze. 

When I step into BSP_HandleButtonInterrupts() , *edge_capture_ptr gets the value of 15. 

 

Any suggestions ??? 

 

Best regards
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
187 Views

fixed 

 

Changed the content of Input Options for user_pb_pio_4in in SOPC builder to ...  

 

Synchronous capture [checked] 

Rising edge [selected] 

Generate IRQ [checked] 

Edge [selected] 

 

No other options was marked 

Made a complete rebuild of SOPC builder and Quartus  

New rebuild with create-this-app / create-this-bsp 

New import into Nios II IDE 

 

0 Kudos
Reply