' EXMP8255.BAS ' ' Example program for SBC1190 digital I/O ' using the onboard 82C55. ' CONST BASE8255 = &HFE40 CONST PORTA = BASE8255 + 0 CONST PORTB = BASE8255 + 1 CONST PORTC = BASE8255 + 2 CONST CTRL55 = BASE8255 + 3 ' The CTRL55 port determines the directions of Port A, B, and C in ' mode 0. The simple digital I/O makes mode 0 the most commonly used mode. ' The following table shows effect of various control byte outputs to CTRL55. ' ' Port A Port B Port C Port C Control Byte ' 7-4 3-0 (CTRL55) ' ' Out Out Out Out 0x80 ' Out Out Out In 0x81 ' Out Out In Out 0x88 ' Out Out In In 0x89 ' Out In Out Out 0x82 ' Out In Out In 0x83 ' Out In In Out 0x8A ' Out In In In 0x8B ' In Out Out Out 0x90 ' In Out Out In 0x91 ' In Out In Out 0x98 ' In Out In In 0x99 ' In In Out Out 0x92 ' In In Out In 0x93 ' In In In Out 0x9A ' In In In In 0x9B ' 'The following line allows output to be redirected out the COM1 port if 'there is no video card installed. Otherwise, QuickBASIC uses direct 'writes to video RAM. OPEN "CONS:" FOR OUTPUT AS #1 PRINT #1, "82C55 Digital I/O test" OUT CTRL55, &H8A ' initialize 82C55 ' Port A - output, Port B - input ' Port C bits 0-3 output ' Port C bits 4-7 input OUT PORTA, &H55 ' output data to Port A DTA = INP(PORTB) ' read data from Port B PRINT #1, "Port B reads "; DTA OUT PORTC, &H55 ' output data to Port C low nibble DTA = ((INP(PORTC)) AND &HF0) / 16' read data from Port C high nibble PRINT #1, "Port C reads "; DTA