REM File: IOEXPIO.BAS Date: 05/08/92 REM REM /* (c) Copyright BLUE EARTH RESEARCH, MANKATO, MN 1992. */ REM /* All rights reserved. */ REM REM The following program allows a user to address the I/O-24 REM Expansion Module as both input and output channels. 2 REM I/O-24 MODULE SAMPLE PROGRAM REM Define variables for external memory addresses 10 RES_L=0E000H : RES_H=0E200H : CTRL=0FB00H 20 PORTA=0F800H : PORTB=0F900H : PORTC=0FA00H REM Initialize the 82C55A for Mode 0, with PORTA as Input, REM PORTB as Output, PORTC(0-3) as Output, and PORTC(4-7) as Input REM For more information on operating modes, refer to Data Sheet 100 XBY(RES_H)=0 : XBY(RES_L)=0 : XBY(CTRL)=98H REM Allow the user to select input or output 110 PRINT : PRINT "Select [I]nput or [O]utput (SPACE to end)" 120 A=GET : IF A=20H THEN END 130 IF A=73.OR.A=105 THEN 200 140 IF A=79.OR.A=111 THEN 300 ELSE 120 REM Input Mode was selected REM Allow the user to select input port 200 PRINT "ENTER WHICH PORT (A OR C) TO READ (SPACE TO END) ", 210 A=GET : IF A=20H THEN END 220 IF A=65.OR.A=97 THEN P=PORTA : GOTO 240 230 IF A=67.OR.A=99 THEN P=PORTC ELSE 210 REM Read the appropriate port 240 X=XBY(P) : PRINT "PORT", CHR$(A), " INPUT =",X 250 GOTO 110 REM Output mode was selected REM Allow the user to specify the port and the output byte 300 PRINT "ENTER WHICH PORT (B OR C) TO OUTPUT (SPACE TO END) ", 310 A=GET : IF A=20H THEN END 320 IF A=66.OR.A=98 THEN P=PORTB : GOTO 340 330 IF A=67.OR.A=99 THEN P=PORTC ELSE 310 340 PRINT CHR$(A) : INPUT "ENTER VALUE TO OUTPUT ",X 350 IF (0<=X.AND.X<256) THEN 370 REM An invalid number was entered, BEEP and request input again 360 PRINT CHR$(7), : GOTO 300 REM Always output 1's to input port pins 370 IF P=PORTC THEN X=X.OR.0F0H REM Output the value to the appropriate port 380 XBY(P)=X : GOTO 110