home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / AMPRO / AAN-8801.TXT < prev    next >
Text File  |  2000-06-30  |  39KB  |  774 lines

  1.                     --------------------------------------
  2.                     AMPRO COMPUTERS, INC. APPLICATION NOTE
  3.                     --------------------------------------
  4.  
  5. Number:  #AAN-8801         Date:  January 5, 1988         Author:  R. Lehrbaum
  6.                       
  7. Title:       Using a SCSI port for generalized I/O.
  8.  
  9. Product(s):  Little Board/Z80, Little Board/186, Little Board/PC
  10.  
  11. Abstract:    If the SCSI bus is not required for connection to "normal" SCSI 
  12.              devices, it can be used as an I/O port, and even as an I/O bus.  
  13.              This ap note explains how this is done.
  14.  
  15. -------------------------------------------------------------------------------
  16.  
  17. SCSI CATCHES ON!
  18. ----------------
  19. Over the past two years, the Small Computer System Interface ("SCSI") has 
  20. begun to be included as a standard feature in the microcomputer products of 
  21. both system manufacturers (such as Apple) and board manufacturers (such as 
  22. AMPRO).  This is a result of three factors:
  23.  
  24.   (1) SCSI has finally been approved by the American National Standards 
  25.       Institute (ANSI X3.131).
  26.  
  27.   (2) Single chip SCSI interface IC's such as the NCR 5380 have become common 
  28.       and inexpensive.  (The 5380 already has at least five alternate sources.)
  29.  
  30.   (3) Hard disk drives such as the Seagate 225N and tape drives such as the 
  31.       Teac MT2ST are now available with "embedded" SCSI controllers.
  32.  
  33. Thanks to the ease of integration and very low cost of including a SCSI 
  34. interface (due to devices like the 5380), designers of microcomputer products 
  35. (systems and boards) now routinely include a SCSI bus controller.  
  36.  
  37.  
  38. ANOTHER WAY TO USE A SCSI PORT
  39. ------------------------------
  40. In a lot of data acquisition and control or embedded microcomputer 
  41. applications, the SCSI port may go unused.  If your system's SCSI bus is not 
  42. required for "normal" SCSI device connection, you may be able to use the SCSI 
  43. interface port as a generalized I/O interface instead.
  44.  
  45. The ability of a SCSI interface to be used for other types of I/O depends 
  46. entirely on the hardware that is being used to generate the SCSI bus signals.  
  47. Some SCSI interface IC's are quite "intelligent", while others are relatively 
  48. "dumb".  In general, because the dumb SCSI IC's require lower level control by 
  49. the system CPU, they provide more direct CPU control over each of the SCSI 
  50. interface signals than do the smarter IC's.  Therefore, the dumber the SCSI 
  51. IC, the more likely it is to be useful as a programmable I/O port.  On the 
  52. other hand, some of the smarter SCSI IC's are too specialized to allow this 
  53. flexibility.  
  54.  
  55. This application note discusses the use of a 5380 SCSI controller IC as a 
  56. generalized I/O interface.  The 5380 offers nearly total control over the 17 
  57. signals which comprise the SCSI bus.  Although the 5380 was not designed to 
  58. serve as a general purpose I/O port, it has several important features which 
  59. make it well suited for this purpose:
  60.  
  61.      o  Open collector output buffers, with 48 mA current sink capability
  62.      o  Schmidt-trigger conditioning on input buffers
  63.      o  Simple CPU bus interface with DMA logic
  64.      o  Seventeen software controlled I/O signals
  65.      o  Handshake and interrupt logic (usable in some applications)
  66.  
  67.  
  68. INSIDE THE 5380
  69. ---------------
  70. The 5380 has 17 bidirectional I/O lines, which may be used as inputs or 
  71. outputs under software control.  It also offers several more advanced features 
  72. including interrupts, request/acknowledge handshaking, and DMA support.  These 
  73. advanced features are intended specifically for SCSI, so they are not very 
  74. flexible; however you may find one or more of them useful in a particular 
  75. application.  
  76.  
  77. To fully understand the 5380 SCSI Protocol Controller device, you should 
  78. obtain a copy of the NCR 5380 Design Manual, available for a nominal charge 
  79. from NCR (see reference below).  In this ap note, we will only focus on the 
  80. simple I/O functions.
  81.  
  82. Within the 5380 are eight readable and eight writable internal ports, normally 
  83. addressed as eight consecutive I/O addresses.  What follows next is a brief 
  84. description of the function of each of the 5380's internal registers.  The I/O 
  85. addresses indicated are the normal offsets from the 5380's base address in 
  86. your system.  Note that all of the SCSI bus signals (at the 5380 IC's pins) 
  87. are "active low," so the actual bus voltage levels are opposite to the 
  88. contents of the corresponding bits in the 5380 registers.
  89.  
  90.      SCSI Data Register (00, read/write):  Writing to this register in the 
  91.      5380 sets the state of the SCSI bus data lines (DB0 through DB7), 
  92.      providing that the "Assert Data Bus" bit of the Initiator Command 
  93.      Register is set.  If you write to this register when the Assert Data Bus 
  94.      bit is not set, the register will hold your data but not assert it on the 
  95.      SCSI bus until the Assert Data Bus bit (in the Initiator Command 
  96.      Register) is set at a later time.  The SCSI Data Register's data bits are 
  97.      assigned as follows:
  98.  
  99.            Bit 7     6       5       4       3       2       1     Bit 0
  100.          +-------+-------+-------+-------+-------+-------+-------+-------+
  101.          :  DB7  :  DB6  :  DB5  :  DB4  :  DB3  :  DB2  :  DB1  :  DB0  :
  102.          +-------+-------+-------+-------+-------+-------+-------+-------+
  103.                                  SCSI Data Register
  104.  
  105.      When you read this I/O port, the value obtained represents the current 
  106.      state of the SCSI bus data lines, DB0 through DB7, except that the actual 
  107.      voltages on the bus lines are inverted relative to the contents of this 
  108.      register.  
  109.  
  110.      Initiator Command Register (01, read/write):  This register is primarily 
  111.      used to control the 5380's SCSI bus interface when the chip is in the 
  112.      Initiator role.  Most functions are also available in the Target role.  
  113.      Two of the bits of this register have different uses when the register is 
  114.      read or written, so two charts are given.  These are as follows:
  115.  
  116.            Bit 7     6       5       4       3       2       1     Bit 0
  117.          +-------+-------+-------+-------+-------+-------+-------+-------+
  118.          :Assert : Arb in: Lost  :Assert :Assert :Assert :Assert :Assert :
  119.          : RST   : Prog  :  Arb  : ACK   : BSY   :  SEL  : ATN   : Data  :
  120.          +-------+-------+-------+-------+-------+-------+-------+-------+
  121.                       Initiator Command Register -- Read Usage
  122.  
  123.            Bit 7     6       5       4       3       2       1     Bit 0
  124.          +-------+-------+-------+-------+-------+-------+-------+-------+
  125.          :Assert : Test  : Diff  :Assert :Assert :Assert :Assert :Assert :
  126.          : RST   : Mode  :  En   : ACK   : BSY   :  SEL  : ATN   : Data  :
  127.          +-------+-------+-------+-------+-------+-------+-------+-------+
  128.                      Initiator Command Register -- Write Usage
  129.  
  130.      As you have probably guessed, the Initiator Command Register allows you 
  131.      to control the state of the RST, ACK, BSY, SEL, and ATN bus signals, and 
  132.      also to control whether the 5380 places its data on the SCSI bus or not.  
  133.      Notice that bits 6 and 5 differ according to whether you are reading or 
  134.      writing this register.  (Refer to the 5380 Design Manual for details on 
  135.      the use of these bits.)  
  136.  
  137.      Here are three restrictions in using these bits to control the SCSI bus:
  138.  
  139.      (1) The 5380 must be in Initiator Mode (Mode Register, bit 6) to be able 
  140.          to set the SCSI control bits ACK and ATN active on the SCSI bus.
  141.  
  142.      (2) If the 5380 is in Initiator Mode (Mode Register, bit 6), then the 
  143.          data bus will not be asserted by the Assert Data Bus bit (Bit 0) 
  144.          unless the SCSI bus I/O signal is false (output from Initiator) and 
  145.          the SCSI bus control signals C/D, I/O, and MSG all match the contents 
  146.          of the Assert bits in the Target Command Register.  
  147.  
  148.      (3) When the Assert RST bit is set, the resulting RST signal on the SCSI 
  149.          bus clears all of the 5380's internal registers!  (Not a very useful 
  150.          general purpose signal, is it?)
  151.  
  152.      Mode Register (02, read/write):  This register contains many control 
  153.      signals governing operation of the 5380.  It allows you to place the chip 
  154.      in either Initiator or Target mode, and provides control over DMA and 
  155.      arbitration functions, parity, etc.
  156.  
  157.            Bit 7     6       5       4       3       2       1     Bit 0
  158.          +-------+-------+-------+-------+-------+-------+-------+-------+
  159.          :Block  : Target: Enable:Enable :Enable :Monitor: DMA   : Arbi- :
  160.          :Mode   : Mode  : Parity:Parity :  EOP  :  BSY  : Mode  : trate :
  161.          :DMA    :       : Check :Int    :  Int  :       :       :       :
  162.          +-------+-------+-------+-------+-------+-------+-------+-------+
  163.                                    Mode Register
  164.  
  165.      This ap note will not cover the use of the bits regarding DMA, parity, 
  166.      arbitration, and interrupts, as these are not required for basic 
  167.      operation of the SCSI interface.  Bit 6 is the most interesting bit of 
  168.      this register, because it determines whether the 5380 is in Target Mode 
  169.      or Initiator Mode.  
  170.  
  171.      Target Command Register (03, read/write):  This register provides control 
  172.      over the bus phase control bits: REQ, MSG, C/D, and I/O, as follows:
  173.  
  174.            Bit 7     6       5       4       3       2       1     Bit 0
  175.          +-------+-------+-------+-------+-------+-------+-------+-------+
  176.          :       :       :       :       : Assert: Assert: Assert: Assert:
  177.          :       :       :       :       :  REQ  :  MSG  :  C/D  :  I/O  :
  178.          +-------+-------+-------+-------+-------+-------+-------+-------+
  179.                               Target Command Register
  180.  
  181.      These bits can only be asserted by the 5380 if the "Target Mode" bit in 
  182.      the Mode Register is set.  In Initiator mode, these bits have a different 
  183.      purpose.  In Initiator Mode, the states of the Assert MSG, Assert C/D, 
  184.      and Assert I/O bits must match the actual state of the bus (which can be 
  185.      read in the Current SCSI Bus Status Register), for data to be placed on 
  186.      the SCSI bus even if the Assert Data Bus bit of the Initiator Command 
  187.      Register is set.  Also, in Initiator Mode, if the Assert MSG, C/D, and 
  188.      I/O bits do match the bus state, then the "Phase Match" bit in the Bus 
  189.      and Status Register will be set.
  190.  
  191.      Select Enable Register (04, write):  This write-only register is used as 
  192.      a mask in Target Mode operation to allow the 5380's built-in selection 
  193.      response logic to generate an interrupt.  Refer to the 5380 Design Manual 
  194.      for more info.
  195.  
  196.            Bit 7     6       5       4       3       2       1     Bit 0
  197.          +-------+-------+-------+-------+-------+-------+-------+-------+
  198.          :  DB7  :  DB6  :  DB5  :  DB4  :  DB3  :  DB2  :  DB1  :  DB0  :
  199.          +-------+-------+-------+-------+-------+-------+-------+-------+
  200.                                Select Enable Register
  201.  
  202.      Current SCSI Bus Status Register (04, read):  This read-only register 
  203.      allows you to read the current state of eight control signals on the SCSI 
  204.      bus.  The bits are utilized as follows:
  205.  
  206.            Bit 7     6       5       4       3       2       1     Bit 0
  207.          +-------+-------+-------+-------+-------+-------+-------+-------+
  208.          : RST   :  BSY  :  REQ  :  MSG  :  C/D  :  I/O  :  SEL  :  DBP  :
  209.          +-------+-------+-------+-------+-------+-------+-------+-------+
  210.                           Current SCSI Bus Status Register
  211.  
  212.      DMA Control Ports (05-07, write):  These are not registers but rather are 
  213.      used as control signals by the 5380's internal DMA logic.  A write 
  214.      operation to one of these three I/O addresses is used as a trigger to 
  215.      begin the corresponding DMA mode (Send, Target Receive, or Initiator 
  216.      Receive).  Refer to the 5380 Design Manual for more information on the 
  217.      use of DMA.
  218.  
  219.      Bus and Status Register (05, read):  This read-only register allows you 
  220.      to read two SCSI bus signals -- ATN and ACK -- which are not included in 
  221.      the Current SCSI Bus Status Register.  In addition, six 5380 status flags 
  222.      which are associated with the optional use of interrupts are read through 
  223.      this register.  The bits of this register are utilized as follows:
  224.  
  225.            Bit 7     6       5       4       3       2       1     Bit 0
  226.          +-------+-------+-------+-------+-------+-------+-------+-------+
  227.          : End   :  DMA  : Parity:Inter- : Phase : Busy  :  ATN  :  ATN  :
  228.          :  of   :Request: Error : rupt  : Match : Error :       :       :
  229.          : DMA   :       :       :Request:       :       :       :       :
  230.          +-------+-------+-------+-------+-------+-------+-------+-------+
  231.                               Bus and Status Register
  232.  
  233.      As mentioned above, the use of DMA and interrupts is not covered in this 
  234.      ap note.  The "Phase Match" bit is handy, in that it shows in a single 
  235.      bit whether the SCSI bus phase matches the settings of the Assert bits 
  236.      (MSG, C/D, and I/O) in the Target Command Register.  The Phase Match bit 
  237.      is only meaningful, however, when the 5380 is in its Initiator Mode 
  238.      ("Target Mode" bit = 0).
  239.  
  240.      The Busy Error bit is set if the Monitor Busy bit in the Mode Register 
  241.      has been set and if the SCSI bus BSY signal becomes false.  If this 
  242.      occurs, the 5380 output drivers all become disabled.
  243.  
  244.      Latched Data Register (06, read):  Reading this register returns the 
  245.      latched -- not current -- state of the SCSI data lines.  Data is latched 
  246.      either during a DMA Target Receive operation when ACK (pin 14) goes 
  247.      active, or during a DMA Initiator Receive when REQ (pin 20) goes active.  
  248.      The DMA Mode bit in the Mode Register must be set before data can be 
  249.      latched in this register.  This register may also be read under DMA 
  250.      control using the 5380's DMA control lines.  The contents of this 
  251.      register are:
  252.  
  253.            Bit 7     6       5       4       3       2       1     Bit 0
  254.          +-------+-------+-------+-------+-------+-------+-------+-------+
  255.          :  DB7  :  DB6  :  DB5  :  DB4  :  DB3  :  DB2  :  DB1  :  DB0  :
  256.          +-------+-------+-------+-------+-------+-------+-------+-------+
  257.                                 Latched Data Register
  258.  
  259.      Reset Parity Interrupt (07, read):  A read of this address is used as a 
  260.      trigger to clear a parity error interrupt.
  261.  
  262.  
  263. SIMPLE I/O
  264. ----------
  265. As indicated above, the 5380 has two operating modes -- Initiator Mode and 
  266. Target Mode -- and in Initiator Mode several constraints govern whether or not 
  267. data from the 5380 can be placed on the SCSI bus signals.  If the 5380 is used 
  268. in the Target mode, however, these constraints are not applicable.  
  269. Consequently, the 5380's Target mode results in more flexible operation for 
  270. simple programmable digital I/O.
  271.  
  272. The 5380 is placed in Target mode by writing 40h to its Mode Register.  Once 
  273. in Target mode, fourteen of the chip's SCSI bus I/O signals can be used as 
  274. bidirectional lines with either input or output capability, and two additional 
  275. lines can be used as input-only lines.  Table 1 gives the breakdown.
  276.  
  277.  
  278.                        Table 1.  5380 Target Mode Usage
  279.  
  280.          5380 Register                Signals            Function
  281.          --------------------------   ----------------   ------------
  282.          SCSI Data Register           DB0-DB7            Bidirectional
  283.          Target Command Register      I/O,C/D,MSG,REQ    Bidirectional  
  284.          Initiator Command Register   BSY,SEL            Bidirectional
  285.          Initiator Command Register   ACK,ATN            Input only 
  286.  
  287. As indicated in Table 1, ACK and ATN are inputs only in the 5380's Target Mode 
  288. of operation.  All of the other SCSI signals except RST can be used as either 
  289. inputs or outputs.  RST is unique in that it clears all of the registers 
  290. within the 5380 whenever it becomes active for any reason (including being set 
  291. by the 5380 itself!).  In most applications you will probably want to avoid 
  292. using the RST signal entirely -- but be sure it is terminated along with the 
  293. other I/O interface signals.
  294.  
  295. The data lines (DB0-DB7) are only enabled as outputs when bit 0 ("Assert Data 
  296. Bus") of the Initiator Command Register is a 1.  However, the state of the 
  297. DB0-DB7 lines can be read whether the Assert Data Bus bit is true (1) or not.  
  298. Since the data lines are Open Collector, they can be switched from output to 
  299. input functions simply by writing all 0's to the SCSI Data Register.  (The 
  300. chip's outputs are inverted, so setting a data bit to 0 turns the output 
  301. driver off.)
  302.  
  303. It is also possible to utilize the 5380's internal interrupt, REQ/ACK, and DMA 
  304. support logic.  For example, one 5380 user has taken advantage of the chip's 
  305. handshake and interrupt functions to monitor the data transmitted by a 
  306. computer's Centronics printer port, using the 5380 as an interrupting 8-bit 
  307. input port.
  308.  
  309. In many 5380-based SCSI systems, there are additional input signals intended 
  310. for the reading of SCSI Initiator ID jumpers.  For example on the AMPRO Little 
  311. Board single board computers, up to eight additional input bits are available 
  312. in this manner if the 5380 is not being used as a SCSI port.  If available, 
  313. these extra input signals can be used to augment the signals provided by the 
  314. 5380, thereby adding up to eight additional input lines.
  315.  
  316. Along the same lines, don't overlook an unused parallel printer port as a 
  317. source of eight more buffered outputs and one or more output and input 
  318. handshake signals.
  319.  
  320. As you can see, a 5380 SCSI interface provides quite a few I/O signals.  The 48 
  321. mA output drive capacity allows long wire lengths, and also can be used to 
  322. drive both mechanical and solid state relays.  
  323.  
  324.  
  325. Example 1 -- Using Opto-22 I/O Modules.
  326.  
  327. Opto-22 manufactures several types of "Mounting Racks" into which you can plug 
  328. optically isolated input and output modules.  Each module functions as either 
  329. a single input bit or a single output bit, and the modules are available in 
  330. both AC and DC versions.  Voltages of up to 240 volts DC or AC can be switched 
  331. or sensed, and the modules provide 4,000 volts isolation!
  332.  
  333. Opto-22's Mounting Racks hold either 4, 8, 16, or 24 optically isolated 
  334. modules, and have model numbers PB4, PB8, PB16, and PB24, respectively.  Since 
  335. the 5380 provides a maximum of sixteen interface signals (as shown in Table 
  336. 1), a single 5380 could interface with up to 16 such I/O modules, using a PB16 
  337. Mounting Rack.  
  338.  
  339. To interface a 5380 with the Mounting Rack's optically isolated input or 
  340. output modules, simply connect each SCSI bus signal (from the 5380) to an 
  341. appropriate pin on the Mounting Rack's edgecard connector.  This can be done 
  342. by constructing a custom "scramble-wired" cable, or you can use a small 
  343. customizable adapter card made by Opto-22 for this purpose, the Model UCA3.  
  344. The UCA3 can accept a 50-pin header edgecard connector from the SCSI side, and 
  345. plugs directly into the Opto-22 Mounting Rack.  The UCA3 has user-programmed 
  346. connection between the input and output bus sides -- that is, it provides two 
  347. 50-pin headers with wire-wrap posts which you wire to suit your needs.
  348.  
  349. The Opto-22 Mounting Rack can accommodate a mixture of input and output 
  350. modules on the same rack.  It is even possible to have a combination of input 
  351. and output modules connected to the eight SCSI data lines (DB0-DB7) at the 
  352. same time.  To allow some of the data lines to function as inputs while others 
  353. function as outputs (at the same time), keep the Assert Data Bus bit in the 
  354. 5380's Initiator Command Register active at all times, and write 0's to any 
  355. bits in the SCSI Data Register that are to be used as inputs.  Because the 
  356. 5380's outputs are open collector (and active low), a bit which is a 0 will 
  357. not drive the bus at all, leaving the corresponding data line free to be 
  358. driven by an input module.
  359.  
  360.  
  361. CONTROLLING AN IC
  362. -----------------
  363. Using the signals illustrated in Table 1 creatively, you can even hook them up 
  364. directly to other IC's.  You can redefine any signal as any desired function.  
  365. For example, some signals can function as address signals, others as control 
  366. signals, still others as data signals.  
  367.  
  368. Many IC's are not too fussy about timings as long as minimum setup and hold 
  369. times are provided.  Using a technique known as "bit banging", you can easily 
  370. satisfy a device's setup and hold requirements.  
  371.  
  372.  
  373. Example 2 -- Interfacing to a Typical LSI Device.
  374.  
  375. As an example, a typical LSI device (such as a UART) might be interfaced to a 
  376. 5380 as shown in Table 2.
  377.  
  378.                         Table 2.  LSI Device Interface
  379.  
  380.          Device Pin  Function                        SCSI Signal Used
  381.          ----------  ----------------------------    ----------------- 
  382.          D0-D7       Data in/out                     -DB0 through -DB7
  383.          A0,A1,A2    Internal register addressing    -I/O,-C/D,-MSG
  384.          -RD,-WR     Read and write (active low)     -SEL,-BSY       
  385.          -CS         Chip select (active low)        -REQ 
  386.  
  387.  
  388. Before going on, a word about logic levels.  The SCSI bus uses active low 
  389. logic levels (i.e., a "0" is the high voltage level and a "1" is the low 
  390. voltage level).  Assuming that the LSI device is "normal", it probably 
  391. requires active high data and address inputs, but active low control signals 
  392. (-RD,-WR,-CS).  Since the 5380 will make everything active low, the data and 
  393. address values written to the 5380's registers must be inverted prior to 
  394. writing to such a device.  
  395.  
  396. In this example, the following sequence might be used for writing to a 
  397. register within the LSI device:
  398.  
  399.   (1) Write a 40h to the Mode Register, to place the 5380 in Target Mode.
  400.          
  401.   (2) Invert the LSI device register address, and then write it to the I/O, 
  402.       C/D, and MSG bits in the Target Command Register while also setting the 
  403.       REQ bit (chip select) to 1.
  404.          
  405.   (3) Invert the data to be written, and then write it to the SCSI Data 
  406.       Register.
  407.  
  408.   (4) Enable data output by writing an 01h ("assert data bus") to the 
  409.       Initiator Command Register.
  410.  
  411.   (5) Turn on the -WR signal by writing an 05h ("REQ" with "assert data bus") 
  412.       to the Initiator Command Register.
  413.  
  414.   (6) Remove the -WR signal by once again writing an 01h to the Initiator 
  415.       Command Register.  This provides write data hold time.
  416.  
  417.   (7) Remove the chip select and address by writing 00h to the Target Command 
  418.       Register.
  419.  
  420.   (8) Disable data output by writing 00h to the Initiator Command Register.
  421.  
  422. You will want to modify this procedure slightly, based on the actual 
  423. requirements of the particular LSI device you need to control.  A similar 
  424. process is used to read the device.
  425.  
  426.  
  427. SYNTHESIZING A BUS
  428. ------------------
  429. Another interesting and potentially powerful use of a 5380 SCSI interface is 
  430. in mimicking the functions of a bus.  Although you can't expect to generate 
  431. anything as complex as a Multibus or VME bus, there are several simple I/O-
  432. oriented buses which can be synthesized adequately using just the 5380 and a 
  433. scramble-wired cable between the 5380 and the bus cards or backplane.  Two bus 
  434. interface examples follow.
  435.  
  436.  
  437. Example 3 -- Interfacing to the "A-Bus"
  438.  
  439. Alpha Products Co. has developed a series of small, low cost data acquisition 
  440. and control cards based on a bus called the "A-Bus".  The A-Bus is easily 
  441. generated by a 5380 SCSI controller IC.  A scramble wired cable or small 
  442. adapter card (available from Alpha Products) is all that is needed, to connect 
  443. between a 5380 and one or more A-Bus cards.  
  444.  
  445. A-Bus cards currently available from Alpha Products include:  analog-to-
  446. digital converters, digital I/O, stepper motor controllers, relay outputs, 
  447. optically isolated inputs, and prototype cards for custom interfaces.  A five 
  448. slot A-Bus motherboard is also available, and multiple motherboards can be 
  449. daisy-chained, so quite a few A-Bus I/O cards can be connected to a single 
  450. 5380 SCSI interface.
  451.  
  452. Table 3 gives the recommended signal mapping between the 5380's SCSI interface 
  453. and the A-Bus backplane signals.  Alpha Products offers a small adapter card 
  454. which provides this interconnection, or you can wire a cable to do this 
  455. yourself.  
  456.  
  457. It is essential that you provide termination on the SCSI/A-Bus bus, since the 
  458. 5380 has open collector outputs.  If you don't, you will get unreliable 
  459. results!  However, the A-Bus devices are not designed to drive the 220/330 ohm 
  460. pullup/pulldown termination normally used on the SCSI bus.  Therefore, you 
  461. must replace the SCSI bus termination networks with higher resistance 
  462. terminators.  For example, you might replace the pullup/pulldown networks with 
  463. 1K pullup devices instead.
  464.  
  465.  
  466.                         Table 3.  SCSI/A-Bus Interface
  467.  
  468.       A-Bus Signal  Pin    Function               SCSI Signal   Pin  
  469.       ------------  ---    --------------------   -----------   ---
  470.       +12 Volts      1     not used; no connect
  471.       -12 Volts      2     not used; no connect
  472.       GROUND         3     Signal Ground          GROUND        odd  
  473.       +5 Volts       4     not used; no connect
  474.       INTERRUPT      5     not used; no connect
  475.       D0             7     Data in/out (LSB)      -DB0           2   
  476.       D1             8     Data in/out            -DB1           4   
  477.       D2             9     Data in/out            -DB2           6   
  478.       D3            10     Data in/out            -DB3           8   
  479.       D4            11     Data in/out            -DB4          10   
  480.       D5            12     Data in/out            -DB5          12   
  481.       D6            13     Data in/out            -DB6          14   
  482.       D7            14     Data in/out (MSB)      -DB7          16   
  483.       A0            15     Address (LSB)          -I/O          50   
  484.       A1            16     Address                -C/D          46   
  485.       A2            17     Address                -MSG          42   
  486.       A3            18     Address (MSB)          -REQ          48   
  487.       -IN           19     Read Strobe            -SEL          44   
  488.       -OUT          20     Write Strobe           -BSY          36   
  489.       ENABLE 0-3   21-24   not used; ground       GROUND        odd  
  490.  
  491.  
  492. Although there are not enough 5380 output signals to generate the four A-Bus 
  493. "Enable" signals, the implementation shown in Table 3 is sufficient to select 
  494. as many as sixteen A-Bus cards.  If the Enable lines are required, you might 
  495. consider pressing an unused parallel port (e.g. Centronics printer port) into 
  496. service.
  497.  
  498. The following two software listings contain typical assembly language code 
  499. which can be used to write to an Alpha products RE-140 relay output card, and 
  500. read from an Alpha Products IN-141 optically isolated digital input card. 
  501.  
  502.                     Listing 1.  Relay Output Card Interface
  503. ; **************************************************************************
  504. ; This is a demo of the Alpha products relay output card
  505. ; using their SCSI adapter.  The code is meant to run on
  506. ; an AMPRO Little Board/Z80 Z80-based single board system.
  507. ;
  508. ; Written 12/01/87 by Rick Lehrbaum
  509. ;
  510. ; Equates:
  511. ;
  512. MODE$REG    EQU    22H    ;Bit 6 used to put in target mode.
  513. TARGET$BIT    EQU    40H    ;Value to write to MODE
  514. ADDRESS$REG    EQU    23H    ;Lower four bits used as A0-A3.  Inverted.
  515. DATA$REG    EQU    20H    ;Eight bits of data.  Inverted.
  516. CONTROL$REG    EQU    21H    ;Used to control data transfer, as follows:
  517.     ; BIT  7  6  5  4  3  2  1  0
  518.     ;                  :  :     +------ ASSERT DATA BUS when = 1
  519.     ;                  :  +------------ READ STROBE when = 1
  520.     ;                  +--------------- WRITE STROBE when = 1
  521. ; Based on these definitions, the read/write functions can use these values:
  522. ASSERT$BIT    EQU    01H    ;Assert data bus.      Write to CONTROL.
  523. WRITE$BIT    EQU    08H    ;Assert write strobe.  Write to CONTROL.
  524. READ$BIT    EQU    04H    ;Assert read strobe.   Write to CONTROL.
  525. ;
  526.         ORG 100H
  527. ;    
  528. INIT:        
  529. ; Initialize the 5380 interface 
  530.         LXI    SP,1000H    ;Set stack pointer
  531.         XRA    A
  532.         OUT    CONTROL$REG    ;Disable all strobes and data bus
  533.         MVI    A,TARGET$BIT
  534.         OUT    MODE$REG    ;Place 5380 in target mode
  535.         JMP    PROGRAM
  536. ;
  537. WRITE:        
  538. ; Writes the data byte in Register C to the I/O card at
  539. ; the address in Register B
  540.         MOV    A,B        ;Get the address from B
  541.         CMA            ;Invert it
  542.         OUT    ADDRESS$REG    ;Put the address on the bus
  543.         MOV    A,C        ;Get the data from C
  544.         CMA            ;Invert it
  545.         OUT    DATA$REG    ;Write it to the data port
  546.         MVI    A,ASSERT$BIT
  547.         OUT    CONTROL$REG    ;Assert the data bus
  548.         MVI    A,ASSERT$BIT OR WRITE$BIT
  549.         OUT    CONTROL$REG    ;Assert the write strobe
  550.         MVI    A,ASSERT$BIT
  551.         OUT     CONTROL$REG    ;Clear the write strobe
  552.         XRA    A
  553.         OUT    CONTROL$REG    ;Release the data bus
  554.         RET
  555. ;
  556. PROGRAM:
  557. ; This a simple sample program intended for the relay output card.
  558. ; It switches each relay on in sequence, and loops indefinitely.
  559.         LXI    B,0001
  560. LOOP:
  561.         CALL    WRITE
  562.         CALL    DELAY
  563.         LXI    B,0002
  564.         CALL    WRITE
  565.                 MOV     A,C
  566.                 RAL
  567.                 MOV     C,A
  568.         JMP    LOOP        ; Loops forever        
  569. ;
  570. DELAY:
  571. ; Delays approximately 1 second.  
  572.         LXI    H,0
  573. DEL01:
  574.         DCX    H
  575.         MOV    A,H
  576.         ORI    0
  577.         JNZ    DEL01
  578.         MOV    A,L
  579.         ORI    0
  580.         JNZ    DEL01
  581.         RET
  582. ;
  583.         END
  584. ; **************************************************************************
  585.  
  586.  
  587.                 Listing 2.  Opto-Isolated Input Card Interface
  588. ; **************************************************************************
  589. ; This is a demo of the Alpha products optically isolated input
  590. ; card using the Alpha Products SCSI adapter.  The code is meant to 
  591. ; run on an AMPRO Little Board/Z80 Z80-based single board system.
  592. ;
  593. ; This demo must be run from DDT or used as a subroutine by another 
  594. ; program.
  595. ;
  596. ; Written 12/03/87 by Rick Lehrbaum
  597. ;
  598. ; Equates:
  599. ;
  600. MODE$REG    EQU    22H    ;Bit 6 used to put in target mode.
  601. TARGET$BIT    EQU    40H    ;Value to write to MODE
  602. ADDRESS$REG    EQU    23H    ;Lower four bits used as A0-A3.  Inverted.
  603. DATA$REG    EQU    20H    ;Eight bits of data.  Inverted.
  604. CONTROL$REG    EQU    21H    ;Used to control data transfer, as follows:
  605.     ; BIT  7  6  5  4  3  2  1  0
  606.     ;                  :  :     +------ ASSERT DATA BUS when = 1
  607.     ;                  :  +------------ READ STROBE when = 1
  608.     ;                  +--------------- WRITE STROBE when = 1
  609. ; Based on these definitions, the read/write functions can use these values:
  610. ASSERT$BIT    EQU    01H    ;Assert data bus.      Write to CONTROL.
  611. WRITE$BIT    EQU    08H    ;Assert write strobe.  Write to CONTROL.
  612. READ$BIT    EQU    04H    ;Assert read strobe.   Write to CONTROL.
  613. ;
  614.         ORG 100H
  615. ;
  616. INIT:        
  617. ; Initialize the 5380 interface 
  618.         LXI    SP,1000H    ;Set stack pointer
  619.         XRA    A
  620.         OUT    CONTROL$REG    ;Disable all strobes and data bus
  621.         MVI    A,TARGET$BIT
  622.         OUT    MODE$REG    ;Place the 5380 in target mode
  623. READ:        
  624. ; Reads the data byte from the I/O card at the address in Register B
  625. ; and returns the data in register C
  626.         MOV    A,B        ;Get the address from B
  627.         CMA            ;Invert it
  628.         OUT    ADDRESS$REG    ;Put the address on the bus
  629.         MVI    A,READ$BIT
  630.         OUT    CONTROL$REG    ;Assert the read strobe
  631.         IN    DATA$REG    ;Read the data
  632.         CMA            ;Invert it
  633.         MOV    C,A
  634.         XRA    A
  635.         OUT    CONTROL$REG    ;Clear the read strobe
  636.         RET
  637.         END
  638. ; **************************************************************************
  639.  
  640.  
  641. Example 4 -- Interfacing to the Opto-22 "PAMUX" Bus
  642.  
  643. Another example of a simple I/O bus which can be easily synthesized by a 5380 
  644. SCSI controller is the Opto-22 "PAMUX" bus.  Like the Alpha Products A-Bus, 
  645. the Opto-22 PAMUX bus is a simple parallel I/O bus with data, address, and 
  646. read and write control signals.  Opto-22 offers an assortment of PAMUX analog 
  647. and digital I/O mounting racks.  Up to 16 PAMUX mounting racks can be daisy-
  648. chained on a single PAMUX ribbon cable bus, and each PAMUX mounting rack can 
  649. hold up to 32 I/O input or output modules, resulting in up to 512 I/O points.
  650.  
  651. As with the Alpha Products A-Bus, all that is required to tie a 5380 SCSI bus 
  652. to the PAMUX bus is a scramble-wired 50 conductor cable.  A suggested wiring 
  653. scheme is given in Table 4.  The Opto-22 Model UCA3 "kludge card" can be used 
  654. to make the bus-to-bus conversion, as described in Example 1.
  655.  
  656.  
  657.                         Table 4.  PAMUX/SCSI Interface
  658.  
  659.       PAMUX Signal  Pin    Function             SCSI Signal   Pin
  660.       ------------  ---    -----------------    -----------   ---
  661.       D0            47     Data in/out (LSB)    -DB0           2
  662.       D1            45     Data in/out          -DB1           4 
  663.       D2            43     Data in/out          -DB2           6
  664.       D3            41     Data in/out          -DB3           8
  665.       D4            39     Data in/out          -DB4          10
  666.       D5            37     Data in/out          -DB5          12
  667.       D6            35     Data in/out          -DB6          14 
  668.       D7            33     Data in/out (MSB)    -DB7          16
  669.       A0             1     Address (LSB)        -I/O          50
  670.       A1             3     Address              -C/D          46
  671.       A2             5     Address              -MSG          42
  672.       A3             7     Address (MSB)        -REQ          48
  673.       A4             9     not used, tie low    GROUND        odd
  674.       A5            11     not used, tie low    GROUND        odd
  675.       WRITE         13     Write Strobe         -BSY          36 
  676.       READ          15     Read Strobe          -SEL          44
  677.       RST           49     not used, tie low    GROUND        odd
  678.       GROUND       even    Signal Ground        GROUND        odd
  679.  
  680.  
  681. Although there are not enough 5380 output signals to generate all six PAMUX 
  682. address signals, the implementation shown in Table 3 is sufficient to select 
  683. up to 128 I/O points (32 I/O's on up to four PAMUX mounting racks).  If more 
  684. address lines are required, they may be able to be provided by an unused 
  685. parallel port (e.g. Centronics printer port) into service.  Be sure to ground 
  686. A4 and A5 in your adapter cable (or on the UCA3).
  687.  
  688. The software routines needed to interface with the PAMUX modules are similar 
  689. to those indicated in Example 3 for the A-Bus.  
  690.  
  691. Here are a few differences from the A-Bus example:
  692.  
  693.   (1) The PAMUX module bits can individually be inputs or outputs.  As 
  694.       mentioned in Example 1, you can support a mixture of input and output 
  695.       modules in the same 8-bit group by writing 0's to the bits in the 5380's 
  696.       SCSI Data Register bits that are to be used as inputs so that those bits 
  697.       on the data bus are free to be driven by the PAMUX input modules.
  698.  
  699.   (2) The PAMUX bus is designed to be terminated with 180/390 ohm 
  700.       pullup/pulldown terminators.  This is too heavy a termination for the 
  701.       5380, so do not use the standard PAMUX "TERM1" terminator.  Instead, use 
  702.       a standard SCSI termination (220/330 ohms) on at least one end -- and 
  703.       preferably both ends -- of the SCSI/PAMUX bus.
  704.  
  705.   (3) All signals on the PAMUX bus are "active high", while all those of the 
  706.       SCSI bus are "active low".  This means that everything must be inverted, 
  707.       including ADDRESS, DATA, and CONTROL SIGNALS.  Consequently, the normal 
  708.       state of the SEL and BSY bits would need to be 1's, rather than 0's, in 
  709.       the 5380's Initiator Command Register.  One or the other of those bits 
  710.       in the 5380 is then set to a 0 to generate a READ or WRITE strobe.
  711.  
  712.   (4) Opto-22 recommends a 2 microsecond minimum duration for the WRITE 
  713.       strobe, and that you delay for at least 2 microseconds from the setting 
  714.       of the READ strobe prior to reading input data.
  715.  
  716.  
  717. THE SCSI/IOP ALTERNATIVE
  718. ------------------------
  719. It is important to remember that all of the techniques of using the 5380 as a 
  720. generalized I/O port discussed in this ap note assume that the 5380 is not 
  721. going to be used for normal SCSI peripheral device connection as well.  This 
  722. means that if you plan to use a SCSI hard disk, tape drive, bubble drive, 
  723. optical drive, RAM disk, or any other such SCSI device, you cannot also use 
  724. the bus for simple digital I/O or to interface with an I/O bus such as the 
  725. Alpha Products A-Bus or the Opto-22 PAMUX bus.
  726.  
  727. A unique device, available from AMPRO Computers Inc., does allow the SCSI bus 
  728. to be used to add data acquisition and control devices along with normal SCSI 
  729. devices.  The SCSI/IOP is a card which acts like a "legal" SCSI target device, 
  730. and inplements an STD Bus device interface.  A SCSI/IOP can be used with a 
  731. single STD Bus I/O card, to add an individual function such as analog or 
  732. digital I/O, or the SCSI/IOP can plug directly into an STD Bus backplane if 
  733. multiple STD Bus I/O cards are required.  The Z80A microprocessor on the 
  734. SCSI/IOP can also be used to run tasks autonomously, so the SCSI/IOP can even 
  735. add improved real time performance and multi-tasking to an non-real-time, and 
  736. single-tasking disk operating systems such as PC-DOS and CP/M.
  737.  
  738.  
  739. REFERENCES
  740. ----------
  741. The following companies were mentioned in this application note:
  742.  
  743.      NCR Microelectronics Division
  744.      1635 Aeroplaza Drive
  745.      Colorado Springs, CO 80916
  746.      Phone:  (303) 596-5612
  747.              (800) 525-2252
  748.  
  749.      OPTO-22
  750.      15461 Springdale St.
  751.      Huntington Beach, CA 92649
  752.      Phone:  (714) 891-5861
  753.              (800) 854-8851  
  754.  
  755.      ALPHA PRODUCTS CO.
  756.      242 West Avenue
  757.      Darien, CT 06820
  758.      Phone:  (203) 656-1806
  759.  
  760.      AMPRO COMPUTERS, INC.
  761.      1130 Mtn. View Alviso Rd.
  762.      Sunnyvale, CA 94089
  763.      Phone:  (408) 734-2800
  764.  
  765.  
  766. -------------------------------------------------------------------------------
  767.   * * * COPYRIGHT (C) 1988, AMPRO COMPUTERS INC. -- ALL RIGHTS RESERVED * * *
  768. -------------------------------------------------------------------------------
  769.  
  770.  
  771.  
  772.  
  773.      
  774.