How to read a real time measurement on Pentium 3?

Hi, I'm running VxWorks Os on a Pentium 3 processor. The VxWorks timers are based on the OS ticks (several mili seconds), but I need a way to measure small time intervals of micro seconds. Is there a Real Time clock register to read, or a cotinueosly running counter register to calculate the interval time from it? Thanks.

Reply to
Rami
Loading thread data ...

The 64 bit Time Stamp Counter (TSC) and the RDTSC instruction should be available on all Pentiums. It counts clock cycles, so you need some means (e.g. the CMOS clock) to first measure the clock frequency, which is quite temperature dependent.

Especially mobile processors entering some kind of sleep mode may give erratic readings.

Paul

Reply to
Paul Keinanen

Thanks. This should do the job. How can I access this register in C code using the GNU compiler? Since RDTSC loads the counter to EDX:EAX, I tried something like this: __asm__("RDTSC"); __asm__("MOV %0,EAX" : "=r"(ulVar) : ");

The code compiled, but downloading it to the target gave an error regarding EAX. Any Ideas? Thank you.

Reply to
Rami

inline unsigned long long rdtsc( ) { unsigned long long ull; __asm__ __volatile__ ( "rdtsc" : "=&A" ( ull ) : ); return ull; }

Reply to
Bryan Hackney

... And don't forget to handle the illegal instruction trap on non-Intel processors that don't do RDTSC...

Reply to
Clifford Heath

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.