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.

demo interrupt

Altera_Forum
Honored Contributor II
1,252 Views

Hello, 

I try to make a simple demo program for interrupt TIMER on my DE2.  

Every second the LEDs on "SORTIES" port whill change. 

 

It does'nt work, could you help me .... In debug mode , i placed a breakpoint in the interrupt routine, but it is never expected. 

 

 

# include "sys/alt_stdio.h" 

# include "system.h" 

# include "altera_avalon_pio_regs.h" 

# include "altera_avalon_timer_regs.h" 

# include "sys/alt_irq.h" 

 

volatile unsigned int contexte_pour_IT; // sauvegarde du contexte de l'IT 

 

static void timer_flash(void* context) 

{static unsigned char n=0; 

n^=0xFF; // toggle bits 

// clear flag IT 

//IOWR(TIMER_0_BASE,ALTERA_AVALON_TIMER_STATUS_REG,ALTERA_AVALON_TIMER_STATUS_TO_OFST); 

IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE,ALTERA_AVALON_TIMER_STATUS_REG); 

IOWR(SORTIES_BASE,0,n); 

 

int main() 

void* Timer_IT_ptr= (void*) &contexte_pour_IT; 

IOWR(TIMER_0_BASE,ALTERA_AVALON_TIMER_CONTROL_REG,ALTERA_AVALON_TIMER_CONTROL_ITO_MSK); 

IOWR(TIMER_0_BASE,ALTERA_AVALON_TIMER_PERIODL_REG,0x3E8); 

IOWR(TIMER_0_BASE,ALTERA_AVALON_TIMER_PERIODH_REG,0); 

alt_ic_isr_register(TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID,TIMER_0_IRQ,timer_flash,Timer_IT_ptr,0); 

alt_irq_init(TIMER_0_BASE); 

 

while(1); 

}
0 Kudos
0 Replies
Reply