home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8635 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  4.3 KB

  1. Path: sparky!uunet!mcsun!uknet!daresbury!doc.ic.ac.uk!rhbnc!csqx.cs.rhbnc.ac.uk!adrian
  2. From: adrian@csqx.cs.rhbnc.ac.uk (A Johnstone)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: Parallel port I/O (mostly O : -)
  5. Message-ID: <1992Aug19.194016.18379@csqx.cs.rhbnc.ac.uk>
  6. Date: 19 Aug 92 19:40:16 GMT
  7. References: <1992Aug19.135359.24909@bas-a.bcc.ac.uk> <1992Aug19.152509.18901@cs.ubc.ca>
  8. Sender: news@csqx.cs.rhbnc.ac.uk (USENET News System)
  9. Reply-To: adrian@csqx.cs.rhbnc.ac.uk (A Johnstone)
  10. Organization: Dept of Comp Sci, Royal Holloway & Bedford New College Uni London
  11. Lines: 89
  12. Nntp-Posting-Host: csqx.cs.rhbnc.ac.uk
  13.  
  14. In article <1992Aug19.152509.18901@cs.ubc.ca>, yogi@cs.ubc.ca (Yossi Gil) writes:
  15.  
  16. <request for info on printer port programming deleted>
  17.  
  18. |> 
  19. |> I recall a byte article on this exact topic few years back. I think it
  20. |> was about 5 or so. I also recal that the max baud rate you can get
  21. |> is 4500. That is 4.5 KB/sec. 
  22.  
  23. A bit of confusion here I think. Firstly baud rate is a term used in the 
  24. context of serial channels. It is named after Baudot, one of the pioneers of
  25. telegraph communication. In, for instance RS-232, the baud rate is the number 
  26. of signal pulses sent per second. The data rate will be less than this because
  27. some start and stop bits are required: hence 300 baud with eight data bits, one
  28. start bit and one stop bit corresponds to a data rate of 30 bytes per second.
  29. I've never seen baud rate used in the context of a parallel channel: assuming
  30. fully parallel transfers I suppose the logical generalisation of the idea would
  31. be the same as the word data rate which is as implied in Yossi's note.
  32.  
  33. A propos the original enquiry: it is very easy to send data out of the parallel
  34. port under program control and you should be able to achieve far higher data
  35. rates than 4.5KB/s with a decent PC. Here are the rough details:
  36.  
  37. The printer port pinout is:
  38.  
  39. 1  OUT strobeL
  40. 2  OUT D0H
  41. 3  OUT D1H
  42. 4  OUT D2H
  43. 5  OUT D3H
  44. 6  OUT D4H
  45. 7  OUT D5H
  46. 8  OUT D6H
  47. 9  OUT D7H
  48. 10 IN  ackL
  49. 11 IN  busyH
  50. 12 IN  paperoutL
  51. 13 IN  selectH
  52. 14 OUT autofeedL
  53. 15 IN  errorL
  54. 16 OUT resetL
  55. 17 OUT selectackL
  56. 18-25 GND
  57.  
  58. The signal names pertain to the Centronics standard and are irrelevant if all you
  59. want to do is send data out. The trailing H and L characters indicate active Low
  60. or active High polarity.
  61.  
  62. The signals are accessed via three registers:
  63.  
  64. I/O port address 0378H printer data register
  65.  
  66. D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0
  67.  
  68. I/O port address 037AH printer control register
  69.  
  70. x | x | x | enable int on ACK | select | reset | autofeed | strobe
  71.  
  72. I/O port address 0379H printer status register
  73.  
  74. busy | acknowledge | paperout | selectack | error | x | x| x
  75.  
  76. The x's above indicate bits that you should ignore on read or leave in their
  77. original state on write. Don't just write zeroes because these bits are used on
  78. some machines for other control purposes.
  79.  
  80. So the bottom line is that something like outportb(0x378,53) will cause decimal
  81. 53 to appear on the printer data lines, and x=inportb(0x379) will read the 
  82. present state of the input lines. The speed at which you can do this is limited
  83. only by the speed of your bus and processor. Normally you will want to handshake
  84. the data transfer with the external device, so you'll need to write the data, 
  85. assert one of the control lines by writing to port 037AH and then monitor one
  86. of the inputs by polling address 0379H for a handshake signal. If you want to
  87. avoid tying your machine up in a polling loop, use the acknowledge line on the
  88. printer port for your external handshake and set bit 4 in the control register.
  89. This will then trigger a printer interrupt every time the acknowledge line is
  90. yanked, and you can then feed data out under interrupt control. For maximum
  91. speed use polling. A grotty PC could probably manage at least 100Kbyte per second
  92. A nice 486 running a tight loop out of internal cache RAM will go much faster.
  93.  
  94. There are other things you might want to know about, such as the fact that the
  95. control outputs are actually open collector outputs and may be used as 
  96. bidirctional I/O lines, and that many manufacturers now do what should have been
  97. done in the first place and allow input from the data lines too. Portables
  98. commonly use this to allow fast parallel I/O to external floppy disks attached
  99. to the printer port for instance. However, I think I've rambled on enough here,
  100. so try that for starters.
  101.  
  102.                                     Adrian
  103.