[comp.sys.mac.hardware] Using the NI-488 board for asynchronous DMA transfer

arneme@cs.uit.no (Arne Munch-Ellingsen) (10/18/90)

-- 
I am working on a project where we wish to use the Eikonix 1400 Scanner to
digitize images. The scanner uses the GPIB (HP-IB) bus for communication
with a Mac-II that has a NI-488 board in slot 2. The version of the NI-488
driver software is 3.0. For some reason we are not able to do asynchronous
DMA transfers of scan lines from the Scanner. In the NI-488 documentation
the routines ibdma (for initialization) and ibrda (for asynchronous reading
of data using DMA from the GPIB bus) are said to allow for DMA transfer. ibwait
is a routine that according to the documentation could be used to wait for
events on the bus.  We use this routine to wait for I/O completion of scan
line transfers and thus synchronize with the scanner.

Her are samples of the code we are using : (Think C v. 4.0 )

void Init_DMA(int BrdNo)
/* Used to prepare the NI-488 for DMA transfer */
{
   if (BrdNo) 
      ibdma( BrdNo, 1);
}

int Wait_Asynk(int lun)
/* Used to synchronize with the NI-488 board */
{
   return ibwait(ccs[lun]->dig_number, CMPL);
}

int Read_Asynk12( int lun, word *data, int npixels, int nsteps, int nscans)
/*
    Scan 12 bit data, several lines at a time, under dma control (?)
*/
{
   extern char cmd[];
   long args[3];
   long count;
   int status;

   args[0] = nsteps;
   args[1] = nscans;

   /* Make comand to the scanner to start scan using DMA (10 = 7 + 3 
      where 7 indicates the use of DMA and 3 indicates 12 bit data) */
   make_cmd( 10, 2, args, cmd);
   /* Send the command to the scanner. This will start the scan */
   if (status = sndcmd( lun, cmd) != NORMAL)
      return status;
   count = 2L * npixels * nscans;
   /* Read the scan data using DMA (doesn't seem to work) */
   status = ibrda( ccs[lun]->dig_number, data, count);
   return status;
}

Somewhere in the code :

   /* Initialize the NI-488 board to prepare for DMA transfers */
   Init_DMA( TheBoard);
   /* Prepare to receive the first line from the scanner */
   scannerstat = Read_Asynk12( lun, Stripe[1], ScanW, SkipL, InStripLength);
   /* Do this while there is more lines to read */
   while (PixLin < PictL) {
      /* Synchronize with scanner */
      Wait_Asynk(lun);
      if (LinjerLest < ScanL) { /* If not last line */
         scannerstat = Read_Asynk12( lun, Stripe[TilBuf], ScanW, SkipL, InStripLength);
         if (scannerstat != NORMAL) break;
            LinjerLest += InStripLength*SkipL;
      } else  /* Last line, send stage home */
          idahom( lun, &stat);
      /* Here comes code that processes the last received scan line
         while the next line should be reiceived to DMA memory. The
         code is ommited */
   }

Any suggestions on what might be the problem ?
 ____________________________________________________________
|     Arne Munch-Ellingsen                                   |
|     Department of Computer Science, University of Tromsoe  |
|     Postboks 953, N-9000 TROMSOE, NORWAY.                  |
|                                                            |
|     Phone :+478344034                                      |
|            +478344053                                      |
|            +478380298  (Home phone)                        |
|                                                            |
|     E-mail: arneme@cs.uit.no                               |
|____________________________________________________________|