Download low_cost_pc-based_quad_channel_r

Transcript
Friday, 21 June 2002
Final Report
Colin K McCord
else
printf(" Baud Rate (Current = 115200 bps)");
printf("\n------------------------------------");
printf("\n
115200 bps -- bit 1");
printf("\n
57600 bps -- hit 2");
printf("\n
38400 bps -- hit 3");
printf("\n
19200 bps -- hit 4");
printf("\n
14400 bps -- hit 5");
printf("\n
9600 bps -- hit 6");
printf("\n
4800 bps -- hit 7");
printf("\n
2400 bps -- hit 8");
printf("\n
1200 bps -- hit 9");
printf("\n
No Change
-- hit 0");
switch(getch())
{
case '1':
baud = 0x01;
break;
case '2':
baud = 0x02;
break;
case '3':
baud = 0x03;
break;
case '4':
baud = 0x06;
break;
case '5':
baud = 0x08;
break;
case '6':
baud = 0x0c;
break;
case '7':
baud = 0x18;
break;
case '8':
baud = 0x30;
break;
case '9':
baud = 0x60;
break;
default:
clrscr();
return;
}
/* set speed */
outportb(COM+LCR, inportb(COM+LCR) | 0x80);
outportb(COM+DLM,baud>>8);
outportb(COM+DLL,baud&0xff);
outportb(COM+LCR,inportb(COM+LCR) & 0x7f);
rate = 115200 / baud;
if(baud != 1) printf("\n\nBaud Rate Changed to %u bps",rate);
else
printf("\n\nBaud Rate Changed to 115200 bps",rate);
clrscr();
}
The source code is reasonable readably (lots of comments and partitioned into many functions), hence if the
reader of this report wises to find out how any other aspect of the program works see appendix ### for the
complete source code.
EEE516J4 – Honours Project
Page 95
Chapter 9: Test Program