![VersaLogic VL-EBX-37 Скачать руководство пользователя страница 31](http://html1.mh-extra.com/html/versalogic/vl-ebx-37/vl-ebx-37_reference-manual_1006785031.webp)
System Features
EBX-37 Reference Manual
25
outp
(
SIOINDEX
,
0x07
);
//Point to Logical
Device Config reg.
outp
(
SIODATA
,
0x0A
);
//Select SMSC Runtime reg.
outp
(
SIOINDEX
,
0x60
);
//Index High Byte of Runtime reg base address.
baseIOHigh
=
inp
(
SIODATA
);
//Read High Byte.
outp
(
SIOINDEX
,
0x61
);
//Index Low Byte of
Runtime reg base address.
baseIOLow
=
inp
(
SIODATA
)
+
RTOFFSET
;
//Read Low Byte and add
offset to runtime reg base.
outp
(
SIOINDEX
, 0xAA
);
//Exit SIO Config mode
Bindex
=
(
baseIOHigh
<<
8
)
+
baseIOLow
;
//Convert high and low
bytes to 16-bit address.
Bdata
=
Bindex
+
1
;
/* Start Hardware Monitoring... */
outp
(
Bindex
,
RLSREG
);
//Index Ready, Lock, Start Reg.
outp
(
Bdata
,
inp
(
Bdata
)
|
START
);
//Set bit 0 to start.
while
(
keypressed
!=
ESC
)
{
if
(
kbhit
())
{
keypressed
=
getch
();
}
/* Read FanTach1 LSB first, latches MSB. */
outp
(
Bindex
,
FANTACHREG
);
//Fantach 1 LSB
FTraw
=
inp
(
Bdata
);
outp
(
Bindex
,
FANTACHREG
+
1
);
//Fantach 1 MSB
FTraw
+=
inp
(
Bdata
) <<
8
;
/* FTraw now contains the number of 90KHz pulses it took to find 5
tach edges. (5 edges = 2 tach pulses = 1 revolution) */
/* Convert Raw to RPMs...
RPM = 1 / (FTraw * 11.11uS / 2) * 60 */
fanRPM
=
FTraw
*
0.00001111
;
fanRPM
/=
2
;
fanRPM
=
1
/
fanRPM
;
_settextposition
(
4
,
1
);
if
(
fanRPM
>
0
)
{
printf
(
"FanTach 1: %5.0fRPMs \n"
,
fanRPM
*
60
);
delay
(
100
);
}
else
{
printf
(
"FanTach 1: Stalled! \n"
);
delay
(
100
);
}
}
exit
(
0
);
}