[ บทความ : ทดลองใช้บอร์ด ET-DIO ตอนที่ 5 ] - Test 8255 (Pascal) |
{ Filename : Out8255.PAS Author : ETT www.etteam.com Hardware : ET-DIO Compiler : Turbo Pascal / DOS Note : ทดสอบการทำงานของ Ic 8255 โดยให้ Ic 8255 ขับหลอดแสดงผล LED เป็นโปรแกรมไฟวิ่ง ทั้ง 3 Port โดยให้ ET-DIO CARD ทำงานที่ Port 300H } Program TestOut8255; Uses Crt; Var StepPort : integer; StepOut : integer; Type DataOut = Array [1..24] of integer; PortNo = Array [1..3] of integer; Const OutValue : DataOut = ($01,$02,$04,$08,$10,$20,$40,$80, $C0,$E0,$F0,$F8,$FC,$FE,$FF,$7E, $3C,$18,$00,$18,$3C,$7E,$FF,$00); { กำหนดการ ติด-ดับ ของ LED ทั้ง 8 Bits } OutPort : PortNo = ($300,$301,$302); Begin Port[$303] := $80; { กำหนด Control Word Code ให้ Control Port ของ 8255 โดยกำหนดให้เป็น OUTPUT ทั้ง 3 Port } For StepPort := 1 to 3 do Begin For StepOut := 1 to 24 do Begin Port[OutPort[StepPort]] := OutValue[StepOut]; Delay(500); End; End; End.
{ Filename : Test8255.PAS Author : ETT www.etteam.com Hardware : ET-DIO Compiler : Turbo Pascal / DOS } program Test8255; uses crt,screen2; Procedure OutPutTest; var StepPort : integer; StepOut : integer; PortShow : string; type Data_Out = Array [1..23] of integer; Port_No = Array [1..3] of integer; const Out_Value : Data_Out = ($01,$02,$04,$08,$10,$20,$40,$80, $C0,$E0,$F0,$F8,$FC,$FE,$FF,$7E, $3C,$18,$00,$18,$3C,$7E,$FF); Out_Port : Port_No = ($300,$301,$302); begin gotoxy(5,3);writeln('[ Output Mode Test ]'); writeln; writeln; port[$303] := $80; { Set 8255 = Output all 3 Port } for StepPort := 1 to 3 do begin if StepPort = 1 then PortShow := ' PA ' else if StepPort = 2 then PortShow := ' PB ' else if StepPort = 3 then PortShow := ' PC '; writeln (' Port ',PortShow,' Under Testing Now'); for StepOut := 1 to 23 do begin Port[Out_Port[StepPort]] := Out_Value[StepOut]; delay(100); end; writeln; end; writeln('Test port PA,PB,PC complete'); for StepPort := 1 to 3 do begin Port[Out_Port[StepPort]] := $00; end; delay(1000); end; procedure inputtest; var InValue1,InValue2,InValue3 : integer; begin clrscr; port[$303] := $9B; { set 8255 = Input all 3 Port } gotoxy(5,3);write('[ Input Mode Test ]'); gotoxy(4,8);write(' Press switch for test '); gotoxy(4,20);write(' Press RETURN to terminated '); repeat SetAttr(ReverseLow); gotoxy(05,11);write(' PA0 '); gotoxy(15,11);write(' PA1 '); gotoxy(25,11);write(' PA2 '); gotoxy(35,11);write(' PA3 '); gotoxy(45,11);write(' PA4 '); gotoxy(55,11);write(' PA5 '); gotoxy(65,11);write(' PA6 '); gotoxy(75,11);write(' PA7 '); gotoxy(05,14);write(' PB0 '); gotoxy(15,14);write(' PB1 '); gotoxy(25,14);write(' PB2 '); gotoxy(35,14);write(' PB3 '); gotoxy(45,14);write(' PB4 '); gotoxy(55,14);write(' PB5 '); gotoxy(65,14);write(' PB6 '); gotoxy(75,14);write(' PB7 '); gotoxy(05,17);write(' PC0 '); gotoxy(15,17);write(' PC1 '); gotoxy(25,17);write(' PC2 '); gotoxy(35,17);write(' PC3 '); gotoxy(45,17);write(' PC4 '); gotoxy(55,17);write(' PC5 '); gotoxy(65,17);write(' PC6 '); gotoxy(75,17);write(' PC7 '); InValue1 := port[$300]; InValue2 := Port[$301]; InValue3 := Port[$302]; If InValue1 And $FF = $FE then Begin SetAttr(LowDisplay); GotoXY(05,11); write(' PA0 '); delay(100); End else If InValue1 And $FF = $FD then Begin SetAttr(LowDisPlay); GotoXY(15,11); write(' PA1 '); delay(100); End else If InValue1 And $FF = $FB then Begin SetAttr(LowDisplay); GotoXY(25,11); write(' PA2 '); delay(100); End else If InValue1 and $FF = $F7 then Begin SetAttr(LowDisplay); GotoXY(35,11); write(' PA3 '); delay(100); End else If InValue1 And $FF = $EF then Begin SetAttr(LowDisplay); GotoXY(45,11); write(' PA4 '); delay(100); End else If InValue1 And $FF = $DF then Begin SetAttr(LowDisplay); GotoXY(55,11); write(' PA5 '); delay(100); End else If InValue1 And $FF = $BF then Begin SetAttr(LowDisplay); GotoXY(65,11); write(' PA6 '); delay(100); End else If InValue1 and $FF = $7F then Begin SetAttr(LowDisplay); GotoXY(75,11); write(' PA7 '); delay(100); End else If InValue2 And $FF = $FE then Begin SetAttr(LowDisplay); GotoXY(05,14); write(' PB0 '); delay(100); End else If InValue2 And $FF = $FD then Begin SetAttr(LowDisplay); GotoXY(15,14); write(' PB1 '); delay(100); End else If InValue2 And $FF = $FB then Begin SetAttr(LowDisplay); GotoXY(25,14); write(' PB2 '); delay(100); End else If InValue2 and $FF = $F7 then Begin SetAttr(LowDisplay); GotoXY(35,14); write(' PB3 '); delay(100); End else If InValue2 And $FF = $EF then Begin SetAttr(LowDisplay); GotoXY(45,14); write(' PB4 '); delay(100); End else If InValue2 And $FF = $DF then Begin SetAttr(LowDisplay); GotoXY(55,14); write(' PB5 '); delay(100); End else If InValue2 And $FF = $BF then Begin SetAttr(LowDisplay); GotoXY(65,14); write(' PB6 '); delay(100); End else If InValue2 and $FF = $7F then Begin SetAttr(LowDisplay); GotoXY(75,14); write(' PB7 '); delay(100); End else If InValue3 And $FF = $FE then Begin SetAttr(LowDisplay); GotoXY(05,17); write(' PC0 '); delay(100); End else If InValue3 And $FF = $FD then Begin SetAttr(LowDisplay); GotoXY(15,17); write(' PC1 '); delay(100); End else If InValue3 And $FF = $FB then Begin SetAttr(LowDisplay); GotoXY(25,17); write(' PC2 '); delay(100); End else If InValue3 and $FF = $F7 then Begin SetAttr(LowDisplay); GotoXY(35,17); write(' PC3 '); delay(100); End else If InValue3 And $FF = $EF then Begin SetAttr(LowDisplay); GotoXY(45,17); write(' PC4 '); delay(100); End else If InValue3 And $FF = $DF then Begin SetAttr(LowDisplay); GotoXY(55,17); write(' PC5 '); delay(100); End else If InValue3 And $FF = $BF then Begin SetAttr(LowDisplay); GotoXY(65,17); write(' PC6 '); delay(100); End else If InValue3 and $FF = $7F then Begin SetAttr(LowDisplay); GotoXY(75,17); write(' PC7 '); delay(100); End; setattr(reverselow); until keypressed; writeln;readln; end; begin clrscr; outputtest; inputtest; end.DOWNLOAD
1. Pascal DOS : 51.7 KB
2. Delphi 2 : 134.0 KB
3. Visual BASIC 4 : 60.9 KB