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 agoYou defined timer as a pointer to int (=32bit) but then you used it with byte address increments, so you are not writing the correct registers.
Anyway this is a deprecated way of programming. A few hints: - use the symbolic defines generated by sopc builder (in system.h file) instead of the numeric addresses 0x10000000, 0x10002000 which would possibly change if you regenerate the system - don't use pointers but rather the IOWR/IORD macros which automatically match the addressed memory data size - in this case it would be even better exploiting the timer control macros (IOWR_ALTERA_AVALON_TIMER_CONTROL, IOWR_ALTERA_AVALON_TIMER_PERIODL, ...) available in the HAL driver.