{ ********************************************************************** ** Program: S1DEB7.PAS Version: 1.1- 8 February 1999 ** ** Firm: GRIFO(r) Via Dell'Artigiano 8/6 ** ** 40016 San Giorgio di Piano (BO) ** ** Tel. 051-892052 FAX 051-893661 ** ** Developed by : Tassinari Enea ** ********************************************************************** This program allows to display the two way direction of the led in ON tatus according to the position of switch 1 of the dip switch. In order to make an easier visualization of the status lines, it is necessary to get a 20 pins flat cable for connecting GPC(r)15R CN9 connector to TIO 16 CN1 connector, or DEB-01 CN15 connector. } program S1DEB7; {$C-} { disable the Ctrl+C } const CNT=$17; { Control and command register of the PPI 82C55 } PDA=$14; { Data register of the A port } PDB=$15; { Data register of the B port } PDC=$16; { Data register of the C port } RIT=100; { Delay of 100 ms } var STATO:byte; TASTO:char; VAL:integer; SWC:integer; RIS:integer; procedure INIZIALIZZAZIONE; { Initialization of the control register of the 82C55 } begin port[CNT]:=130; end; function LETTURA (INDIRIZZO:integer):byte; { Read the dip switch status } begin LETTURA:=port[INDIRIZZO]; end; procedure SCRITTURA (STATO:integer); { Write on A-C port } var BYTEL,BYTEH:byte; begin BYTEL:=STATO and $FF; { Write into BYTEL variable only the low byte value of the contents of the STATO variable } BYTEH:=(STATO and $FF00) shr 8; { Write into BYTEH variable only the high byte value of the contents of the STATO variable. The value came shift of 8 position in right direction so you can see the BYTEH contents like low byte value. } port[PDA]:=BYTEL; port[PDC]:=BYTEH; end; begin {program main } clrscr; INIZIALIZZAZIONE; gotoxy(10,3); writeln('VISUALIZATION OF THE LED RUN ON A-C PORT IN PROGRESS'); gotoxy(25,4); write('Press any key for exit'); gotoxy(6,6); write('Change the switch 1 position of the dip switch to inverte the run'); begin SCRITTURA($FFFF); { Led of A-C port in OFF } SWC:=LETTURA(PDB); RIS:=SWC and 1; { Sensibilize only switch 1 of the dip switch } if RIS=0 then VAL:=1 { The switch 1 reading involve the lighting of the firs or last LED. } else VAL:=$8000; repeat begin SCRITTURA($FFFF-VAL); delay(RIT); SWC:=LETTURA(PDB); { Read the B port } RIS:=SWC and 1; { Mask the switch } if RIS=0 then begin if VAL=$8000 then VAL:=1 { You can lighting in sequence the last and first LED. } else VAL:=VAL shl 1; { You can shift in left direction the middle bits. } end else begin if VAL=1 then VAL:=$8000 { You can lighting in sequence the firs and last LED. } else VAL:=VAL shr 1; { You can shift in right direction the middle bits. } end end; until keypressed; end; SCRITTURA($FFFF); { Led OFF in the end time. } read(kbd,TASTO); end.