RDTSC for measuring time

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:RDTSC for measuring time

Post by Candy »

hsimola wrote: Those other things you mentioned goes too diffcult for me.

I have PC's from Pentium II to Pentium 4, mostly laptops.
they involve ripping out your processor and soldering on it, so it's probably out of the question anyway.

Can't you make an external card containing its own counter etc. all working at 4mhz or something, and then clock its count in the processor? say you make the input connect to the invert-input on a flipflop that controls the enable-pin of a 24-bit counter, and when you get the disable-signal (inverse of enable) you start sending the count. That no idea?
hsimola

Re:RDTSC for measuring time

Post by hsimola »

Yes, that's also good idea. But I would like to work only with PC, not external cards.

What is your final opinion about STROBE pin compared to ACK pin or serial port pins ?

PS. I am starting developing Microchip PIC based external card, but it will take time when it is ready. So, I try with PC first.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:RDTSC for measuring time

Post by Candy »

hsimola wrote: Yes, that's also good idea. But I would like to work only with PC, not external cards.
Most people don't notice when you have a very small control thingy in your connection cable :) And then again, you can make it so small you can put it inline in a small box... does cost some more...
What is your final opinion about STROBE pin compared to ACK pin or serial port pins ?
I don't know if ACK will be fast enough, but I guess they're both equally fast. The strobe pin might have a slightly faster response because the data must be read within a microsecond, but I think ACK also has that.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:RDTSC for measuring time

Post by Brendan »

Hi,
hsimola wrote: Frequencies I feed to serial port CTS pin are between 10-100Hz.
I don't see anything wrong with using CTS for <= 100 Hz....

As I mentioned you should be able to get 0.001 uS resolution using RDTSC, so I guess the question is, why isn't your original code this accurate?

To start with your first measurement should be discarded, as it will measure part of a cycle rather than a full cycle. You could wait for a rising edge before you start counting to remove this problem.

Other than this your accuracy will depend on how you calibrate RDTSC, how you interpret the results, and if your CPU's/RDTSC's clock remains at a fixed frequency (it can be messed up by automatic thermal monitoring, but it's unlikely).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
hsimola

Re:RDTSC for measuring time

Post by hsimola »

Yes, that's true, first RDTSC value should be discarded.

But I use array where I store values. So, only in array[0] is wrong value.

Running out of ideas...
Post Reply