A SERVICE OF

logo

45
4.5) Reading the Digital I/O Lines
There are 16 TTL compatible Digital Inputs and 16 TTL compatible Digital Outputs on
the PC62C. These can be read and written too using the DIO Register (offset 20).
A Pascal example of how to read and write to the digital ports is given below:
Program Digitaltest(Input, Output);
{ This program test the digital input and output lines. On the PC62C
connector, connect the digital input lines [DIN0 to DIN15] to the
Digital Output Lines [DOUT0 to DOUT15] respectively. The aim is to
write a value from 1 to 65535 and read it back using the Digital
Input Lines. If an error occur during the read or write, a ‘failure’
message will be displayed else a ‘pass’ message will be displayed. }
VAR I, j, k : longint;
Count, dummy : longint;
Begin
Count := 10; { Repeat test 10 times }
for i := 1 to count do { external digital I/O test }
begin
k := 0;
error := 0; { initialise error count to 0 }
for k := 1 to 65535 do
begin
portw[ba+20] := k; { write to the digital output lines
dummy := portw[ba+20]; { read these lines back }
if dummy <> k then { verify if they correspond }
begin { If not then increment the error count }
error := error + 1;
end; { Digital I/O compare }
end;
if error <> 0 then {If error detected then display failure}
begin
gotoxy(10,10)
write(‘Digital I/O Test Fail: ’, error);
end
else begin {If no error was detected the display pass }
gotoxy(10,10)
write(‘Digital I/O Test Pass: ’, error);
end;
end; { test count to 10 }
end. { End Program }