Forum Discussion
Altera_Forum
Honored Contributor
12 years agotimer problem
I'm new to altera and c-programming. Just can't make the internal timer work. int main(void) { volatile int * red_leds =(int*) 0x10000000; volatile int * timer =(int*) 0x1000200...
Altera_Forum
Honored Contributor
12 years agothanks for answer, i've started to use macroses, but timer still isn't working.
# include "system.h" # include "altera_avalon_timer_regs.h" # include "altera_avalon_pio_regs.h" int main(void) { //turning timer on // 1/(50 MHz) x (0x1DCD6500) = 10 sec IOWR_ALTERA_AVALON_TIMER_PERIODL (INTERVAL_TIMER_BASE + 0x8, 0x6500); IOWR_ALTERA_AVALON_TIMER_PERIODH (INTERVAL_TIMER_BASE + 0xC,0x1dcd); IOWR_ALTERA_AVALON_TIMER_CONTROL (INTERVAL_TIMER_BASE + 0x4, 0x4); run=IORD_ALTERA_AVALON_TIMER_STATUS(INTERVAL_TIMER_BASE); run=(run & 0x00000002); IOWR_ALTERA_AVALON_PIO_DATA(RED_LEDS_BASE, 0); ///////////////////////////////////////////// while (run) // { IOWR_ALTERA_AVALON_PIO_DATA(RED_LEDS_BASE, 0x2AA); } while(1) { IOWR_ALTERA_AVALON_PIO_DATA(RED_LEDS_BASE, 0); } }