// timer2
Æ
for Machine Independent Timer
/* address of timer 2 = wAd2*4
address of ctrl
= wAd3*4
input clock
= 8 M
down count 8 time = 1
μ
s
down count 65536/8 = 8192
μ
s --> max 8191
μ
s
*/
WORD P180X_DelayUs(WORD wDelayUs)
{
WORD wDownCount,wLow,wHigh,wVal;
double fTimeOut;
if (wDelayUs>=8191) return(InvalidateDelay);
wDownCount=wDelayUs*8;
wLow=wDownCount&0xff;
wHigh=(wDownCount>>8)&0xff;
outport((wAd3*4), 0xb0); /* timer_2 mode_0 0xb0 */
outport((wAd2*4), wLow);
outport((wAd2*4), wHigh);
fTimeOut=1.0; // wait 1 to stop
for (;;)
{
wVal=inport(wAddrCtrl)&0x01;
if (wVal!=0) return(NoError); /* if the timer is up, this bit will be 1 */
f=1.0;
if (fTimeOut>6553500.0)
return(DelayTimeOut);
}
}
z
P1202_DelayUs(…) is designed for PCI-1202H/L/HU/LU
z
P1602_DelayUs(…) is designed for PCI-1602 and PCI-1602F
PCI-1202/1602/1800/1802 Hardware User’s Manual
(
Ver.4.2, Dec/2009, PMH-014-42)---- 38