#86994 - Ant6n - Sun Jun 11, 2006 7:24 am
Hi,
i have a little issue with a high speed timer on VBA. i am running timer 2 and 3 in count up style with timer 2 in mode 1 (cpu clock speed), and i have an u32 count up everytime timer 3 overflows - to get a general purpose 64bit timer.
everything seems to work fine, but my main loop, which looks like this...:
...prints this:
Now, why are some of the numbers the same (which would imply that gcc just optimized the two calls to time_cycles() despite everything being volatile, even the return type of that function), yet others are different?
My suspicion is that the emulator doesnt do timers that well, but i am still puzzled about this?
does anybody know why the loop takes like 30~50K clock cycles; does VBA only allow a print every 1ms or something?
thx
anton
i have a little issue with a high speed timer on VBA. i am running timer 2 and 3 in count up style with timer 2 in mode 1 (cpu clock speed), and i have an u32 count up everytime timer 3 overflows - to get a general purpose 64bit timer.
everything seems to work fine, but my main loop, which looks like this...:
Code: |
while(1) { x = time_cycles(); y = time_cycles(); sprintf(text,"time %d, %d \n",x,y); agbprint(text); } |
...prints this:
Quote: |
time 108, 108 time 28444, 28500 time 78660, 78660 time 129580, 129740 time 188100, 188100 time 248012, 248012 time 307420, 307800 time 368220, 368220 time 429400, 429780 time 491948, 491948 ... |
Now, why are some of the numbers the same (which would imply that gcc just optimized the two calls to time_cycles() despite everything being volatile, even the return type of that function), yet others are different?
My suspicion is that the emulator doesnt do timers that well, but i am still puzzled about this?
does anybody know why the loop takes like 30~50K clock cycles; does VBA only allow a print every 1ms or something?
thx
anton