
Using the I/O Address Map
DAI12-4(FIT)GY
33
Sample program
/*======================================================
Sample program 1
DEVICE ID:
0
Mode:
Software Mode, Partially
Transparent
Channel:
0 to 3ch
Range:
-10 to 10V
Internal Clock:
N/A
Interrupt:
N/A
====================================================== */
#include <stdio.h>
#include <conio.h>
/* ----- Constant -------------------------------------- */
#define ADR
0x0800
/* I/O address */
/* ----- Prototype ------------------------------------- */
void main( void );
/* ----- Main ------------------------------------------ */
void main( void )
{
unsigned char
UpperData = 0x0c;
unsigned char
LowerData = 0x00;
unsigned char
i;
float
VDAT;
outp( ADR+0x18, 0x00 );
/* Initialize */
outp( ADR+0x18, 0x02 );
/* D/A Conversion Mode */
outp( ADR+0x1c, 0x00 );
/* Software */
outp( ADR+0x18, 0x03 );
/* Range */
outp( ADR+0x1c, 0x00 );
/* -10 to 10V */
VDAT = (UpperData*0x100+LowerData)*20.0f/4096.0f-10.0f;
for(i = 0; i < 4; i++) {
while( ( (unsigned char)inp( ADR+0x16 ) ) & 0x01 );
outp( ADR+0x12, 0x00+i ); /* Set Channel */
outp( ADR+0x10, LowerData ); /* Set Lower Data */
outp( ADR+0x11, UpperData ); /* Set Upper Data */
while( !((unsigned char)inp( ADR+0x16 ) & 0x02) );
printf("%01dch %02x%02x %7.3f[V]\n", i, UpperData,
LowerData, VDAT);
}
}
/* ----------------------------------- End of file --- */
Содержание DAI12-4FITGY
Страница 1: ...F eIT Series Isolated Analog Output Module DAI12 4 FIT GY User s Manual CONTEC CO LTD...
Страница 47: ...Using the I O Address Map 42 DAI12 4 FIT GY...
Страница 64: ......