Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Programming of Timer Interrupt???

I have set up one NIOS2, one ONCHIP_RAM(4K), one INTERNAL_TIMER and four PIO in the SOPC builder. my board use 25Mhz osicllation.

I want to design a timer interrupt routine, just for glittering the LEDs.

int main (void) __attribute__ ((weak, alias ("alt_main")));

alt_u8 x = 0x5;

static void timer_interrupts(void* context, alt_u32 id)

{

IOWR_ALTERA_AVALON_TIMER_STATUS(SYS_TIMER_BASE, 0);//clear TO

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, x);//light LEDs

if(x==5)x=0xA;

else x=5;

}

int alt_main (void)

{

alt_irq_register(SYS_TIMER_IRQ, (void*)&x, timer_interrupts);

IOWR_ALTERA_AVALON_TIMER_PERIODL(SYS_TIMER_BASE, 0xBC20);

IOWR_ALTERA_AVALON_TIMER_PERIODH(SYS_TIMER_BASE, 0xBE);

IOWR_ALTERA_AVALON_TIMER_CONTROL(SYS_TIMER_BASE, 7);

while (1)

{

;

}

return 0;

}

built complete!!!

when I downlaod program to EP1c12, but the console said verify failed http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif

what&#39;s wrong with my routine???

the hardware is ok and i can download the hello_led routine.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Verified failed? Sounds to me like memory problem. Have you check the .elf size is it <4k? or as svhb pointed out: is the data and address ports connected to the CPU?