Appendix
EC71813CLD2NA SERIES
49
Digital IO Programming Guide
The board provides 16channel programmable digital IO pins, eight for input while
the other eight for output.
The following provides digital I/O program in C language; please follow the steps
below to implement digital I/O programming:
Ø
Initialize digital I/O
Ø
Input/output program
(1)
Initialize digital I/O:
#define
BAR 0x400
unsigned char tmp_val;
outportb(BAR,0xbf);
outportb(BAR+0x04,0x40);
outportb(BAR+0x03,0x03);
outportb(BAR+0x05,0x0f);
tmp_val =(inportb(BAR+0x02)|0x08)&0xeb;
tmp_val |= 0x40;
outportb(BAR+0x02, tmp_val);
delay(30);
tmp_val =inportb(BAR);
while((tmp_val &0x02)!=0x02)
{
tmp_val =inportb(BAR);
if((tmp_val &0x04)!=0)
{
printf("ERROR\n");
return 0;
}
}
outportb(BAR,0xbf);
outportb(BAR+0x04,0x42);
outportb(BAR+0x03,0x03);