Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Problem wid nios ii APIs

Honored Contributor II

Hello all, 

I'm using Quartus v13.1 on my DE2-70 board with the cyclone II fpga. I want to enable interrupts using toggle switches. It worked when using the Altera ehanced interrrupt API (#include"altera_avalon_pio_regs.h"), However I tried using the nios 2 API (because we have some tutorials using it ) and It does not seem to work. For eg: 


I tried using the functions such as : __builtin_wrctl(3, 2) and __builtin_wrctl(0, 1) to write into the ienable and status register respectively. When i read the ipending register (ipending = __builtin_rdctl(4)) it shows 0 . I also tried replacing it with the nios 2 macros without much success. Here is the code i used: 


#include <stdint.h> 

#include <stdio.h> 

#include <stdlib.h> 

#include <unistd.h> 

#include "system.h" 

#include "nios2.h" 

volatile uint32_t *LED = (volatile uint32_t *) LEDS_BASE; /* Green leds base address*/ 

volatile uint32_t * slides = (volatile uint32_t *) 0x41000; /* slider switches base address*/ 



void toggle_isr() 

int press; 

press = *(slides+3); /* read the switch edge capture register*/ 

//*(slides+3) = 0; /* clear the interrupt */ 

printf("Hello from Nios 3! \n"); 


printf("Hello from Nios I4! \n"); 

if ((press & (1 << 1)) != 0) /* SW[1] */ 

printf("Hello from Nios II! %d \n", *LED); 

if(*LED == 0xFF) 

*LED = 0; 



void interrupt_handler(void) 

int ipending, status; 

printf("Hi! \n"); 


printf("HhgfghfjhgfghfI! %d \n", status); 


printf("Hello from Nios II! %d \n", ipending); 

//if (((ipending & (1 << 1))) != 0 ) // toggle switches is interrupt level 1 

if (ipending != 0) // checking for enabled interrupts in general*/ 

printf("Hello from Nios 2! %d \n", ipending); 


// else, ignore the interrupt 


int main() 

*(slides+2) = 0x3;  


NIOS2_WRITE_STATUS(1); /* enable Nios II interrupts*/  


return 0; 



Is there a reason why it is not working (errors in the code above, obsolete functions …)? 




0 Kudos
0 Replies