EasyManua.ls Logo

BENECOM BPC-201 - Appendix A DIO (Digital I;O) Sample Code; Digital I;O Sample Code

Default Icon
36 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Appendix A
35
BP
C
-2010-NW
C
U
ser’s Manual
Appendix A
DIO (Digital I/O) Sample Code
//============================================
//BPC-201 DOS DIO sample program
//Please compile with Turbo C 3.0 to utilized the program
//============================================
void main(){
int RetVal;
outp(0x2E,0x87);
outp(0x2E,0x01);
outp(0x2E,0x55);
outp(0x2E,0x55);
outp(0x2E,0x07);
outp(0x2F,0x07);
outp(0x2E,0x27);
outp(0x2F,0xFF);
outp(0x2E,0xc2);
outp(0x2F,0xff);
outp(0x2E,0xca);
outp(0x2F,0xf0);
//Reset Output Pins to all zero
//IO Port: 0xa22
//DIO_OUT 1 is bit 4
//DIO_OUT 2 is bit 5
//DIO_OUT 3 is bit 6
//DIO_OUT 4 is bit 7
RetVal=inp(0xa22);
RetVal=RetVal&0x0f;
outp(0xa22,RetVal);
system("pause");
//Turn on all Output Pins to all
RetVal=inp(0xa22);
RetVal=RetVal|0xf0;
outp(0xa22,RetVal);
system("pause");
//Read Input pins
//IO Port: 0xa22
//DIO_IN 1 is bit 0
//DIO_IN 2 is bit 1
//DIO_IN 3 is bit 2
//DIO_IN 4 is bit 3
RetVal=inp(0xa22);
RetVal=RetVal&0x0F;
printf("DI 1-4= %d",RetVal);
system("pause");
}