Recent

Author Topic: Accurate timing ~1ms...  (Read 3513 times)

wildfire

  • Full Member
  • ***
  • Posts: 110
Accurate timing ~1ms...
« on: April 08, 2013, 10:50:11 pm »
Hi again,

Going back to my emulator (it's a 6510 BTW), I'm now looking at timing accuracy.

My current thought is to use a timer that triggers every 25ms which executes 25000 clock cycles (1Mhz processor) and stalls the virtual CPU until the timer triggers again.

I'm thinking 25ms as any less is not reliable (at least under windows OS) and any more would likely be noticable.

Does anyone have an idea of a better approach?
« Last Edit: April 08, 2013, 11:33:34 pm by wildfire »
A halo is a mere circle, when does it end?

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 661
Re: Accurate timing ~1ms...
« Reply #1 on: April 08, 2013, 11:11:48 pm »
If your windows8 will allow you to use the MMSYSTEM unit, you'll find a better timer there (for multimedia use) than the standard windows timer.  It's been a while, but I think it lets you get down to 5ms or so.

However -- my experience is that windows just isn't real-time friendly no matter what you do  :(

wildfire

  • Full Member
  • ***
  • Posts: 110
Re: Accurate timing ~1ms...
« Reply #2 on: April 08, 2013, 11:37:49 pm »
Thanks Curt, I'll take a look at that.

Apologies for the brain fart earlier, I've amended my post (obviously it wasn't 400 clock cycles)
A halo is a mere circle, when does it end?

irfanbagus

  • Jr. Member
  • **
  • Posts: 73
Re: Accurate timing ~1ms...
« Reply #3 on: April 09, 2013, 02:33:09 am »
just an idea, but works on my opengl application as walkaround to driver bug with vsync

1. find your period (p), 25ms in your case
2. save your current time (t0)
3. run your process
4. save your current time (t1)
5. if t1 less than t0+25ms go to step 4. optional, you can sleep before go to step 4 to save power.
6. t0 = t1 - (t1-t0) mod p
7. go to step 3

chrnobel

  • Sr. Member
  • ****
  • Posts: 283
Re: Accurate timing ~1ms...
« Reply #4 on: April 09, 2013, 04:28:29 pm »
Can't you use EpikTimer in some way?

Christian

wildfire

  • Full Member
  • ***
  • Posts: 110
Re: Accurate timing ~1ms...
« Reply #5 on: April 10, 2013, 02:20:12 am »
Would work in conjunction with irfanbagus's method chrnobel,I'll look into it (it may be possible to reduce the period down to 10 or even 5ms with EpikTimer).

Does anyone know if EpikTimer is thread safe?-
 
A halo is a mere circle, when does it end?

 

TinyPortal © 2005-2018