Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!comp.vuw.ac.nz!csc.canterbury.ac.nz!phys169 From: phys169@csc.canterbury.ac.nz Newsgroups: comp.lang.pascal Subject: Re: Interrupt type stuff Message-ID: <1990Dec7.172551.10137@csc.canterbury.ac.nz> Date: 7 Dec 90 05:18:57 GMT References: <25202@adm.brl.mil> Organization: University of Canterbury, Christchurch, New Zealand Lines: 48 In article <25202@adm.brl.mil>, chaudhury@physics.ucla.edu (CHAUDHURY, SHILADITYA) writes: > I have a programmable parallel port whose starting address I know. I now > need to use this I/O port to read a button i.e., when the button is pressed > (sort of like Jeopardy buzzers) my program goes and takes data and locks out > the button till it is ready for more data. I would naturally like to do > this in TP 4+. Parallel printer ports normally have 3 registers: 3Bc/378/278 Printer data (output, readbale, but don't trust it to be bi-directional). (Bit 0 comes out on pin 2..bit 7 on pin 9) 3BD/379/279 Printer status register (input) pin 11 (BUSY) -> bit 7 pin 10 (ACK) -> bit 6 pin 12 (PAPER) -> bit 5 pin 13 (ONLINE)-> bit 4 pin 15 (ERROR) -> bit 3 3BE/37A/27A Printer control register (output) Bit 4 -> allow IRQ generation (interrupt-driven printer IO doesn't work well) Bit 3 -> pin 17 (might allow printer data port to go into input mode, probably won't, and trying it might cook chips). Bit 2 -> pin 16 (initialise printer) Bit 1 -> pin 14 (auto linefeed) Bit 0 -> latch data output Of course, you don't need to use the port to connect to a printer. Use pull-up resistors (4.7kohm) to a +5v supply, and put switches from input pins to earth. Don't feed inputs into output pins. Programming would be something like: var LptPort : array[1..4] of word absolute $40:8; BaseAddr: word; InputBits : byte; begin BaseAddr:=LptPort[1]; repeat InputBits:=port[BaseAddr+1] xor $FF; {change this depending on switch type} if boolean(InputBits and $F8) then begin {acknowledge which switch is on by testing bits 3-7} repeat InputBits:=port[BaseAddr+1] xor $FF; until (InputBits and $F8)=0; until Whatever; end; Hope this helps, Mark Aitchison. Brought to you by Super Global Mega Corp .com