home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / ref / ports.doc < prev    next >
Text File  |  2006-10-19  |  4KB  |  101 lines

  1. James Yi 73327,1653  Feb. 20, 1987
  2.  
  3. Here are some known INP/OUT ports.
  4. Their values X can be read by:
  5. X=INP AND (b)  where b=2^ bit number
  6. and outted by OUT,# statement.
  7.  
  8.  
  9. Input port:
  10.  
  11. INP(187)
  12.  
  13.    bit 2 - Printer port BUSY line (pin #25) status:
  14.    1 = not busy, 0 = busy
  15.  
  16.    bit 3 - Barcode reader port (pin #2) condition:
  17.    1 = not grounded, 0 = grounded
  18.  
  19.    bit 5 - If the phone line is connected:
  20.    0 = carrier or data on the phone line, 1 = no carrier
  21.  
  22.  
  23. Out ports:
  24.  
  25. OUT184,# (Reset button will reset any of these)
  26.  
  27.    bit 1 - disable all keys accept for BREAK and PAUSE.
  28.  
  29.    bit 2 - freeze the computer.
  30.  
  31.    bits 1 & 2 - power off, then resume when turned back on.
  32.  
  33. OUT184,195 - resets the frequency of tone generator.
  34.  
  35. OUT185,#
  36.  
  37.    bits 0 through 7 is a data byte for the printer.
  38.  
  39. OUT186,# (its status can be read)
  40.  
  41.    bit 4 - power off.
  42.  
  43.    bit 5 - buzzer toggle (1 = enable tone generator).
  44.  
  45.    bit 7 - send a pulse to the phone line.
  46.  
  47. OUT186,47 - turns tone generator off.
  48.  
  49. OUT188,a OUT189,b (a = 0 to 255, b = 64 to 128)
  50.  
  51.    Sends frequency values to the tone generator.
  52.  
  53.    To use the tone generator execute the following:
  54.    OUT186,32:OUT188,a:OUT189,b:OUT184,195
  55.  
  56. OUT232,# (to send any character to the printer, strobe an ACK signal
  57.           through this port after a character is latched to port 185)
  58.  
  59.    bit 0 - ACK signal of the printer port:
  60.    1 = low, 0 = high
  61.  
  62.    bit 1 - cassette motor on/off:
  63.    1 = MOTORON, 0 = MOTOROFF
  64.  
  65.    bit 2 - phone line relay for TELCOM:
  66.    1 = on, 0 = off
  67.  
  68.  
  69. Using the printer port to interface to the real world:
  70.  
  71. The BUSY line of the printer port and Barcode reader port can detect a low/high signal.  By combining these two inputs with the DATA lines of the printer port 16 independent inputs are possible.
  72.  
  73. This can be done by having the DATA lines 'select' which inputs are to be read by port 185.  Since each DATA line can have either a 1 or 0 depending on what value was sent to the port they can be tied to the BUSY line (pin #25) and give different inputs.
  74.  
  75. For example if DATA line 0 (pin #3) is connected to BUSY line, sending a value of 254 (1xor255) which pulls bit 0 low and the others high will give a not busy signal, and sending 255 will give a busy signal.
  76.  
  77. In this way the status of a switch connected between a DATA line and BUSY line can be read, and 8 switches can be connected to one input line and read one at a time.  To demonstrate this run the following:
  78.  
  79.  
  80. 10 CLEAR512:X$=SPACE$(255):X=-65536+PEEK(VARPTR(X$)+1)+PEEK(VARPTR(X$)+2)*256:M=X-1
  81. 11 M=M+1:READK:IFK<>-8THENPOKEM,ABS(K):IFK<0THENREADK:K=K+X:POKEM+1,(K-INT(K/256)*256)MOD256:POKEM+2,256+INT(K/256):M=M+2:GOTO11ELSE11
  82. 100 DATA 14,127,121,211,185,219,187,230,4,15,15,15,122,63,23,87,121,15,79,-218,3,35,126,35,102,111,114,201,-8
  83. 200 J$=SPACE$(1):CLS:PRINT@0,"Bits :"
  84. 220 CALLX,,VARPTR(J$)
  85. 230 J=ASC(J$)
  86. 240 FORL=7TO0STEP-1
  87. 250 V=2^L:IFJ-V>=0THENJ=J-V:PRINTCHR$(27)+"p"
  88. 260 PRINT@(7-L)*2+10,CHR$(L+48);:PRINTCHR$(27)+"q"
  89. 270 NEXT
  90. 280 GOTO220
  91.  
  92.  
  93. After running it, if a jumper wire is placed between BUSY line and a DATA line (pins 3,5,7,9,11,13,15,17) the corresponding bit will show in inverse graphics.
  94.  
  95. Machine code is used to read the port, it can be done in Basic but the value latched to port 185 drifts and only machine code can read it before it escapes.
  96.  
  97. Note: the machine code is stored in a character string so it is safe to run on either the 100 or 200.
  98.  
  99.  
  100. Edited by Robert Benson
  101.