
28
•
Control Programming
outportb(DATA,MOD15);//initial port 1 as mod
//15 for input
outportb(INDEX,PA1);
//index to port A 1
input = inportb(DATA);//read PA1
To initial 8253
# define INDEX 0x300 //INDEX same as SW
//setting
# define DATA 0x301 //data R/W port
# define CW53 0x83
//8253 control port
# define CWD531 0x30 //8253 counter 1 CW
# define CWD532 0x74 //8253 control 2 CW
# define CWD533 0xB0 //8253 control 3 CW
outportb(INDEX,CW53);//index to 8253 control
//port
outportb(DATA,CWD531);//initial counter 1
outportb(DATA,CWD532);//initial counter 2
outportb(DATA,CWD533);//initial counter 3
To set event counter
# define INDEX 0x300 //INDEX same as SW
//setting
# define DATA 0x301 //data R/W port
# define CW530 0x80 //event counter index
outportb(INDEX,CW530);//index to counter 1
outportb(DATA,0x32); //write 32H to low byte
outportb(DATA,0x0); //write 0H to high byte
To set timer
# define INDEX 0x300 //INDEX same as SW
//setting
# define DATA 0x301 //data R/W port
# define CW531 0x81 //timer 1 index
# define CW532 0x82 //timer 2 index
outportb(INDEX,CW531);//index to timer 1
outportb(DATA,0x30); //write 30H to timer 1
//low byte
outportb(DATA,0x10); //write 10H to timer 1
//high byte
outportb(INDEX,CW532);//index to timer 2
outportb(DATA,0x10); //write 10H to timer 2
//low byte
outportb(DATA,0x00); //write 00H to timer 2
//high byte