4. Using the I/O Address Map
ADI16-4(FIT)GY
41
Sample program
/*===========================================================================
=
Sample program 2
DEVICE ID:
0
Mode:
Clock Mode, Multi-Channel
Channel:
0 to 3ch
Range:
-10 to 10V
Internal Clock:
250msec (250ns x 1,000,000)
Interrupt:
N/A
===========================================================================
*/
#include <stdio.h>
#include <conio.h>
/* ----- Constant ----------------------------------------------------------
*/
#define
ADR
0x0800
/* I/O address */
#define
NUM
10
/* Sampling Times */
/* ----- Prototype ---------------------------------------------------------
*/
void main( void );
/* ----- Main ---------------------------------------------------------------
- */
void main( void )
{
unsigned char
UpperData, LowerData, sts;
unsigned char
GainData, OffsetData;
unsigned int
i, j;
float
VDAT;
outp( ADR+0x18, 0x00 );
/* Initialize */
outp( ADR+0x18, 0x02 );
/* Sampling Mode */
outp( ADR+0x1c, 0x05 );
/* Clock */
outp( ADR+0x18, 0x07 );
/* FIFO Flag */
outp( ADR+0x1c, 0x20 );
outp( ADR+0x18, 0x03 );
/* Range */
outp( ADR+0x1c, 0x00 );
/* -10 to 10V */
outp( ADR+0x18, 0xb );
/* Factory Setting(Gain) */
outp( ADR+0x1c, 0x20 );
while( inp( ADR+0x17 ) & 0x4 );
GainData = (unsigned char)inp( ADR+0x1c );
outp( ADR+0x18, 0xa );
/* set Gain Data*/
outp( ADR+0x1c, 0x0 );
outp( ADR+0x1d, GainData );
while( inp( ADR+0x17 ) & 0x8 );
outp( ADR+0x18, 0xb );
/* Factory Setting(Offset)
*/
outp( ADR+0x1c, 0x21 );
while( inp( ADR+0x17 ) & 0x4 );
OffsetData = (unsigned char)inp( ADR+0x1c );
outp( ADR+0x18, 0xa );
/* set Offset Data*/
outp( ADR+0x1c, 0x1 );
outp( ADR+0x1d, OffsetData );
while( inp( ADR+0x17 ) & 0x8 );
outp( ADR+0x18, 0x04 );
/* Timer Data */
outp( ADR+0x1c, 0x3f );
/* 250ns x 1,000,000 */
outp( ADR+0x1d, 0x42 );
outp( ADR+0x1e, 0x0f );