#22893 - jhinders - Wed Jun 30, 2004 9:29 pm
ok, i am trying to use a timer and basically i check it in a while loop:
Now i would assume that i would get values for Ticks that would go up at a fairly steady rate, but am not. i will get a difference of 13 between the current Ticks value and the next, and then sometimes get like 34 or something. Anyone know what stupidity i am doing?
thanks.
Code: |
while(1) { CumulateTicks(); } #define REG_TM2D ( *(vu16*)0x4000108 ) #define REG_TIM2CNT ( *(vu16*)0x400010A ) #define FREQUENCY_64 (1) #define TIMER_ENABLE (1<<7) #define TIMER_MS (REG_TM2D / (262144/1000)) static void ResetTimer() { REG_TIM2CNT = 0; REG_TM2D = 0; REG_TIM2CNT = FREQUENCY_64 | TIMER_ENABLE; } static unsigned int Ticks = 0; static void CumulateTicks() { static DWORD cumulate = 0; DWORD ms = TIMER_MS; Ticks += ms; cumulate += ms; ResetTimer(); } |
Now i would assume that i would get values for Ticks that would go up at a fairly steady rate, but am not. i will get a difference of 13 between the current Ticks value and the next, and then sometimes get like 34 or something. Anyone know what stupidity i am doing?
thanks.