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

Programming of Timer Interrupt???

Altera_Forum
Honored Contributor II
984 Views

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.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
259 Views

Is the RAM also connected to the data port of the processor?

0 Kudos
Altera_Forum
Honored Contributor II
259 Views

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?

0 Kudos
Reply