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

Registering ISR results in Nios II hanging forever.

SNass
Beginner
1,908 Views

Hey everyone,

 

I've been trying to register an ISR for an interval timer in my platform designer system but with no success. Every time I call the function alt_ic_isr_register, the Nios II seems to hang indefinitely. This problem also occurs when using the legacy interrupt API.

 

My system is supposed to increment a global variable every time the timer rollsover.

 

Here is my code:

 

alt_u32 timer;

 

static void handle_timer_interrupt(void* context) {

timer++;

}

 

bool init_timer() {

int ret_val;

timer = 0;

ret_val = alt_ic_isr_register(TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID, TIMER_0_IRQ, handle_timer_interrupt, NULL, 0x0);

 

// ISR registration failed

if(ret_val < 0)

return false;

 

IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, ALTERA_AVALON_TIMER_CONTROL_CONT_MSK | ALTERA_AVALON_TIMER_CONTROL_START_MSK | ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);

 

return true;

}

 

After tracing the problem down using printf, I found that the program hangs when alt_iic_isr_register gets called. More specifically, in the file "alt_iic_isr_register.c", the program does not progress past the line "alt_irq_enable_all(status);" (line 98). I found this by modifying the file as such:

 

printf("Enabling IRQs\n");

  alt_irq_enable_all(status);

  printf("IRQs enabled\n");

 

Which resulted in the console only printing "Enabling IRQs"

 

I've tried this with other interrupt sources such as the PIO core but it fails in the same manner.

 

Does anyone have any hints as to what could be wrong here? Any feedback is greatly appreciated.

0 Kudos
1 Reply
Ahmed_H_Intel1
Employee
1,127 Views
0 Kudos
Reply