{ ********************************************************************** ** Program: S1DEB8.PAS Version: 1.1- 16 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 an incrementa counter on ports. 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 S1DEB8; {$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 B port } begin LETTURA:=port[INDIRIZZO]; end; procedure SCRITTURA (STATO:integer); { Write on A and 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); griteln('VISUALIZATION OF THE LED COUNTER ON A-C PORT IN PROGRESS'); gotoxy(25,4); write('Press any key for exit'); gotoxy(14,6); write('Change the switch 1 position to inverte the counter'); begin SCRITTURA($FFFF); { Led of the A-C port in OFF } SWC:=LETTURA(PDB); RIS:=SWC and 1; { Sensibilize only the 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:=$FFFF; repeat begin SCRITTURA(VAL); delay(RIT); SWC:=LETTURA(PDB); { Read the dip switch status } RIS:=SWC and 1; { Mask the switch } if RIS=0 then VAL:=VAL+1 { You can do the positive counter or negative counter } else VAL:=VAL-1 end; until keypressed; end; SCRITTURA($FFFF); { Led off in the end time } read(kbd,TASTO); end.