Forum Discussion
Altera_Forum
Honored Contributor
11 years agoInitialize the interrupt in your main application code this way:
// register the timer irq to be serviced by handle_timer_interrupt() function
alt_irq_register(SYS_CLK_TIMER_IRQ, 0, handle_timer_interrupt);
// activate the time
IOWR_ALTERA_AVALON_TIMER_CONTROL(SYS_CLK_TIMER_BASE,
ALTERA_AVALON_TIMER_CONTROL_CONT_MSK
| ALTERA_AVALON_TIMER_CONTROL_START_MSK
| ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);
This is the template for the interrupt service function:
void handle_timer_interrupt(void*p, alt_u32 param)
{
// clear irq status in order to prevent retriggering
IOWR_ALTERA_AVALON_TIMER_STATUS(SYS_CLK_TIMER_BASE, 0);
// your isr code here
// ....
}