Forum Discussion

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

how to use timer

hello all

I use the timer core ,but when i write the timer there is something wrong with it .

my programm is :

void handle_time_interrupt()

{

IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 0x0b);

count++;

if(count==1)

{

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xfe);

}

if(count==2)

{

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xfd);

}

if(count==3)

{

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xfc);

}

if(count==4)

{

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,0xfb);

count=0;

}

}

void init_time()

{

IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 0x07);

alt_irq_register( TIMER_0_IRQ ,

NULL,

handle_time_interrupt );

}

int main()

{

count=0;

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xaa);

init_time();

while (1)

{

}

return 0;

}

the time is 5 second,and i only see the result of 0xfb,cann't see the oxfd and 0xfc
No RepliesBe the first to reply