39
KUBE-8040 User’s Manual
Appendix A
DIO (Digital I/O) Sample Code
//============================================
//KUBE-8040 Series DOS DIO sample program
//Please compile with Turbo C 3.0 to utilized the program
//============================================
int main()
{
int
RetVal;
//Clear DIO_OUT 1~4
RetVal=inp(0x50d);//IO Port: 0x50d
RetVal=(RetVal&0xCF);//DIO_OUT 1 is bit 4
//DIO_OUT
2
is
bit
5
outp(0x50d,RetVal);
RetVal=inp(0x50e);//IO Port: 0x50e
RetVal=(RetVal&0xFB);//DIO_OUT 3 is bit 2
outp(0x50e,RetVal);
RetVal=inp(0x53a);//IO Port: 0x53a
RetVal=(RetVal&0xFE);//DIO_OUT 4 is bit 0
outp(0x53a,RetVal);
system("pause");
//Setting DIO_OUT 1~4
RetVal=inp(0x50d);//IO Port: 0x50d
RetVal=(RetVal|0x30);//DIO_OUT 1 is bit 4
//DIO_OUT
2
is
bit
5
outp(0x50d,RetVal);
RetVal=inp(0x50e);//IO Port: 0x50e
RetVal=(RetVal|0x04);//DIO_OUT 3 is bit 2
outp(0x50e,RetVal);
RetVal=inp(0x53a);//IO Port: 0x53a
RetVal=(RetVal|0x01);//DIO_OUT 4 is bit 0