I used a multifunction Counter/Timer and digital I/O card (advantech
PCL-836) under QNX 4.25.
The program is such as follow:
#define baseadd 0x200
unsigned int time,lowbyte,hibyte;
// initiate the timer
outp(baseadd+0x03,0x34); // 10MHZ freqency divided by 10
outp(baseadd+0x12,0x02); // set inter clock
outp(baseadd+0x0b,0x30); // set operation mode 0
// set the timer
// read the timer
// stop the timer
printf("\n %d us,lowbyte:%x,hibyte:%x",(unsigned int)time,lowbyte,hibyte);
1.Every time the value i got is not so accurate ,that is the value sometimes
ranges greatly ,which is about tens of us.
But i test this program at Turbo C 3.0 under DOS,this is not case,the timer
works properly,and the rang is about 1 or 2 us.Even i use the function
delay(1) ,it got the satisifing result ,the value is 2001 or 2002 us.
Then i _disable() the interrupts under QNX. The range of the value dereases
,which is no more than 2 us (only the test results for the excution time of
the ‘for’ loops ) .But the another strange things occurs.
When i add another setprio(0,25) followed ,the value of the timer ranges
from many hundred of millionseconds in contrast to the only setprio() one
If there is one setprio() in the programe ,whatever the priprity you set,
the value of the timer got is almost the same. So you can conclude that
the value of the timer depends on
the amount of the setprio() function you have used.
I can’t tell which is the true time of the excution time of the loops of
Any help will be appreciated!