Hello,
You can find this information in the chapter 24 (Interval Timer Core) of the Quartus II Handbook Volume 5 : Embedded Peripherals (
http://www.altera.com/literature/hb/nios2/n2cpu_nii5v3.pdf). Else, here is a code where a counter is incremented according to timer interrupt and the value is displayed on leds
#include "system.h"# include "sys/alt_irq.h"# include "altera_avalon_pio_regs.h"# include "altera_avalon_timer_regs.h"
void handleTimerInterrupt (void* context, alt_u32 id)
{
static alt_u8 value = 0x00;
value = value + 1;
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, ~value); // Display the value with leds
IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0); // Clear the interrupt flag
}
int main (void)
{
alt_irq_register(TIMER_IRQ, 0, handleTimerInterrupt); // Register the ISR for timer
while(1);
}