4. Using the I/O Address Map
42
ADI16-4(FIT)GY
outp( ADR+0x1f, 0x00 );
outp( ADR+0x12, 0x03 );
/* Channel data */
outp( ADR+0x18, 0x05 );
/* Conversion Start & Timer Start
*/
for(i = 0; i <NUM; i++) {
do {
sts = (unsigned char)inp( ADR+0x16 );
} while( !( sts & 0x01 ) );
for(j = 0; j < 4; j++) {
LowerData = (unsigned char)inp( ADR+0x10 );
UpperData = (unsigned char)inp( ADR+0x11 );
VDAT = (unsigned int)(UpperData*0x100+LowerData)*20.0f/65536.0f-
10.0f;
printf("%01dch Input Data:%02x%02x Input Voltage:%7.3fV\n", j,
UpperData, LowerData, VDAT);
}
sts = (unsigned char)inp( ADR+0x16 );
outp( ADR+0x16, sts & 0x10 );
/* Status reset */
if( sts & 0x20 ) {
i = NUM;
printf("\nClock Error\n");
} else printf("\n");
}
outp( ADR+0x18, 0x06 );
/* Timer Stop */
}
/* ---------------------------------------------------------- End of file ---
*/