home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / APOG / DMADOC.ZIP / DMA.DOC next >
Encoding:
Text File  |  1991-03-19  |  9.7 KB  |  244 lines

  1.    ----------------------------------------------------------------------
  2.    ----------------------------------------------------------------------
  3.    DOCUMENT:
  4.                      PROGRAMMING DMA I/O WITH VMDMA
  5.                                Version 1.0
  6.                               March 8, 1991
  7.  
  8.                Programming and Documentation by Ryan Hanlon
  9.            Copyright (c) 1991,  Covox, Inc.  All Rights Reserved
  10.    ----------------------------------------------------------------------
  11.    GENERAL DESCRIPTION 
  12.        
  13.        The recording and playback of non-compressed 8 bit PCM sound
  14.        data via DMA (memory to port, port to memory), can be achieved
  15.        by setting the Voice Master card and mother board DMA controller
  16.        properly. This document will supply all of the raw information
  17.        you will need to write recording and playback software for the
  18.        Voice Master and the Sound Master II boards.
  19.        
  20.        The Voice Master is only capable of being set to use IRQ 3 or IRQ 7 
  21.        while the Sound Master II board can use any one of IRQ's 3 through 7. 
  22.        Both the Voice Master and the Sound Master II were designed to use
  23.        DMA channel 1 or channel 3 and one of the port ranges starting at
  24.        0x0220, 0x0240, 0x0280, or 0x02C0.
  25.  
  26.        NOTE : Except for the IRQ changes on the Sound Master II the 
  27.        functionality of the Voice Master is replicated on the Sound 
  28.        Master II board. For the duration of this document all references
  29.        to the Voice Master (VMDMA), apply equally to the Sound Master II
  30.        board. 
  31.  
  32.        This document should be used in conjunction with the document and
  33.        source code supplied with the program sm2detec.exe.
  34.  
  35.    ----------------------------------------------------------------------
  36.    VOICE MASTER PORTS
  37.  
  38.      BASE PORTS
  39.        Jumper setting positions 1 through 4 determine the BASE PORT of
  40.        the Voice Master.  
  41.  
  42.        0x0220 to 0x022F,
  43.        0x0240 to 0x024F,
  44.        0x0280 to 0x028F,
  45.        0x02C0 to 0x02CF    
  46.  
  47.      BASE PORT OFFSETS
  48.        The BASE PORT plus (+) the BASE PORT OFFSET can be used to access the
  49.        ports on the Voice Master.  As can be seen below only port offsets
  50.        from 0x08 and 0x0F are used on the Voice Master.
  51.  
  52.        8254 TIMER 0 OFFSET   =   0x08   Timer/Clock
  53.        8254 TIMER 1 OFFSET   =   0x09   Timer/Clock
  54.        8254 TIMER 2 OFFSET   =   0x0A   Timer/Clock
  55.        8254 CONTROL OFFSET   =   0x0B   Timer/Clock control register
  56.  
  57.        CLEAR IRQ OFFSET      =   0x0C   \
  58.        DISABLE VMDMA OFFSET  =   0x0D    > VMDMA Control ports
  59.        ENABLE VMDMA OFFSET   =   0x0E   /
  60.  
  61.        DAC OFFSET            =   0x0F   The DAC OFFSET port should
  62.                                          not be written to during DMA
  63.                                          i/o.
  64.    ----------------------------------------------------------------------
  65.    VMDMA CONTROL PORT OFFSETS
  66.  
  67.      DISABLE DMA OFFSET   =   0x0D
  68.        Writing to this port will disable DREQ (DMA Request), channel 1
  69.        or DREQ channel 3 thus preventing all VMDMA i/o.
  70.  
  71.  
  72.      ENABLE DMA OFFSET    =   0x0E
  73.        Writing to this port should be done last and only after all clock and
  74.        DMA setup has been completed.  A write to this port will fire off 
  75.        a DREQ (cause the DREQ line to go low), thus allowing the VMDMA i/o
  76.        to begin.
  77.  
  78.  
  79.      CLEAR IRQ OFFSET      =   0x0C
  80.        This BASE PORT offset is to be utilized after every DMA
  81.        terminal count is reached.  It is common to find this port
  82.        being written to inside an interrupt handler.  Any value
  83.        may be output to the port.
  84.  
  85.     ----------------------------------------------------------------------
  86.    INTEL 8254 COUNTER/TIMER ONBOARD THE VOICE MASTER
  87.    
  88.      The Voice Master is equipped with the Intel 8254 programmable interval
  89.      counter/timer. COUNTER 2 is used for DMA i/o control.  COUNTER 1 and 3
  90.      are not used by the Voice Master and are available for general purpose
  91.      use within software.
  92.  
  93.      TIMER 0 OFFSET = 0x08    TIMER 1 OFFSET = 0x09    TIMER 2 OFFSET = 0x0A    
  94.  
  95.      8254 CONTROL OFFSET = 0x0B
  96.  
  97.      COUNTER 2 is setup to fire off DREQ's at given intervals by
  98.      latching to the 8254 CONTROL OFFSET port in LSB/MSB order.
  99.      The formula you will need to properly program this DREQ
  100.      frequency is shown below.
  101.  
  102.                         7.1MHz
  103.          i/o rate  =  ------------   where N is a 16 bit divisor that
  104.                           N          is written, 8 bits at a time,
  105.                                      to one of the TIMER OFFSETs.
  106.                            
  107.      Each DREQ sent by the Voice Master is received by the 8237 DMA
  108.      controller on the mother board.  After one 8 bit DMA read or write is
  109.      performed the 8237 sends a DACK (DMA Acknowledged), signal to the Voice
  110.      Master board.  This DACK signal effectively disables the Voice Master
  111.      from sending another DREQ to the 8237 until CLOCK 2 reaches zero again.
  112.          
  113.      Bit settings for the CONTROL port of the 8254.  
  114.        
  115.       bits 7,6 =  00 timer 0    bits 5,4 = 00 latch preset
  116.                   01 timer 1               01 read/write only MSB
  117.                   10 timer 2               10 read/write only LSB
  118.                                            01 read/write LSB, then MSB
  119.  
  120.       bits 3,1 = 000 mode 0     bit    0 =  0 binary
  121.                  001 mode 1                 1 BCD decrementing
  122.                  010 mode 2
  123.                  011 mode 3
  124.                  100 mode 4
  125.                  101 mode 5
  126.  
  127.   ----------------------------------------------------------------------
  128.    8237 DMA CONTROLLER ON THE MOTHERBOARD
  129.  
  130.      The DMA on the mother board should be completely setup for i/o
  131.      only after the Voice Master board has had the DREQ lines
  132.      disabled. (See DISABLE VMDMA OFFSET for more information).
  133.  
  134.      The recommended settings for performing recording or playback 
  135.      are as follows : 
  136.          1. single mode
  137.          2. address increment
  138.          3. no automatic reinitialize
  139.          4. read or write (depending on desired results)
  140.          5. channel 1 or 3 (depending on jumper setting on Voice Master)
  141.  
  142.      Bit settings for the control byte of the 8237.  
  143.         bits 7,6 = 00 demand mode
  144.                    01 single mode 
  145.                    10 block mode
  146.                    11 cascade mode
  147.                    
  148.         bit  5   =  0 address increment
  149.                     1 address decrement
  150.  
  151.         bit  4   =  0 no automatic reinitialize
  152.                     1 automatic reinitialize
  153.                     
  154.         bits 3,2 = 00 verify
  155.                    01 write
  156.                    10 read
  157.  
  158.         bits 1,0 = 00 channel 0
  159.                    01 channel 1
  160.                    10 channel 2
  161.                    11 channel 3
  162.       
  163.  
  164.    ----------------------------------------------------------------------
  165.  
  166.    DMA BUFFER - 20-BIT SEGMENT ADDRESS
  167.  
  168.    Bits 2 and 3 of the byte written to the 8237 DMA CONTROLLER determine
  169.    whether DMA recording or playback will be performed.  Both DMA i/o
  170.    directions require that the start address of a data buffer be output
  171.    to the DMA ADDRESS REGISTER and the physical page be outp to the 
  172.    DMA PAGE REGISTER.
  173.  
  174.  
  175.    EXAMPLE : 
  176.    
  177.    This example uses a long named temp_address to store the 20 bit 
  178.    address of a Test_Buffer of char.  First the page address of Test_Buffer
  179.    is outp to the DMA PAGE REGISTER.  The remaining 16 bit address
  180.    is outp to the DMA ADDR REGISTER.  Channel 1 is the active settings
  181.    of the Voice Master for this example.
  182.  
  183.    /* Get 20 bit address of test buffer
  184.    */
  185.    temp_address = ((long)FP_SEG(Test_Buffer))<<4) + (long)FP_OFF(Test_Buffer);
  186.  
  187.  
  188.    /* Output segment page address of test buffer to the DMA PAGE REGISTER
  189.    // for channel 1.
  190.    */
  191.    outp( DMA_CH1_PAGE_REGISTER, (unsigned char)(temp_address >> 16) );
  192.  
  193.      
  194.    /* Set the address of the test buffer.  outp LSB then MSB.
  195.    */
  196.    outp( DMA_CLEAR_LSB_MSB, 0x00 );
  197.    outp( DMA_CH1_ADDR_REGISTER, (unsigned char)(temp_address) );
  198.    outp( DMA_CH1_ADDR_REGISTER, (unsigned char)(temp_address >> 8) );
  199.  
  200.    ----------------------------------------------------------------------
  201.  
  202.    DMA BUFFER - CURRENT BUFFER SIZE
  203.  
  204.    The size of the current buffer being used with DMA i/o should be
  205.    output to the DMA COUNT REGISTER.  Special considerations need to be
  206.    made for buffers that  cross page boundaries.
  207.    
  208.  
  209.    EXAMPLE : 
  210.  
  211.    This example assumes that the length of Test_Buffer is stored in a
  212.    variable named Test_Buffer_Count. Since the DMA predecrements this
  213.    count before a byte is processed we add 1 to the count before it
  214.    is outp to the DMA COUNT REGISTER.  Channel 1 is the active settings
  215.    of the Voice Master for this example.
  216.    This example does not check to see if the length of the buffer exceeds
  217.    the available length left before the page boundary. 
  218.  
  219.       /* Set word count on DMA channel 1.
  220.       */ 
  221.       outp( DMA_CLEAR_LSB_MSB, 0x00 );
  222.       outp( DMA_CH1_COUNT_REGISTER, Test_Buffer_Count + 1 );
  223.       outp( DMA_CH1_COUNT_REGISTER, 0x00 );
  224.  
  225.       /* Enable 8237 DMA on the mother board
  226.       */
  227.       outp( DMA_MASK_REGISTER , DMA_CH1);
  228.  
  229.  
  230.    ----------------------------------------------------------------------
  231.  
  232.    IMPORTANT PROGRAMMING CONSIDERATIONS
  233.  
  234.    1. Disabling and enabling of the DMA subsystem can cause an IRQ to fire
  235.       off.
  236.  
  237.    2. When the terminal count is reached on the 8237 DMA controller the
  238.       DACK line on the Voice Master goes high.  To set this line to 
  239.       low and thus allow the next interrupt to occur you must
  240.       outp( (vmdma_base_port + VMDMA_CLEAR_IRQ_OFFSET), 0) directly before
  241.       issuing an  outp(0x20,0x20) in your interrupt handler.
  242.  
  243.  
  244.