Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DMA with CDO DIO (PCIe6251m)

Hi --

I'm working on a driver for M-Series devices (PCIe6251m). I generate digital waveforms on the Port 0 DIO lines using FIFO to store the digital samples.
Because M Series devices have a DMA controller dedicated to moving data from the system memory to the DO waveform generation FIFO, my next work is to implement this.
Does anyone have a few lines of sample code that would nudge me in the right direction? (programmation of CDIO_DMA_Select_Register).

thanks!
0 Kudos
Message 1 of 3
(7,042 Views)

Hi imer-

I don't have time to create an example now, but I can give you some tips that might help you get started.

First, the values for CDIO_DMA_Select:

Bits 7..4 are CDO_DMA_Select.  Bits 3..0 are CDI_DMA_Select.  Possible values for both values are as follow (other values are undefined):

0: No DMA Channel will be assigned for this operation
1: DMA Channel 0 will be assigned for this operation
2: DMA Channel 1 will be assigned for this operation
3: DMA Channel 4 will be assigned for this operation
4: DMA Channel 2 will be assigned for this operation
5: DMA Channel 5 will be assigned for this operation
8: DMA Channel 3 will be assigned for this operation

In addition, you will need to program the DMA controller on the board using the method shown in the "generic dma library" that's available with the MHDDK downloads.  The method to access functions in that library is shown in several of the AI examples from the M Series MHDDK.  Check out aiex3.cpp, for example. 

This line (  mite->setAddressOffset(0x500);  ) sets the address offset for the DMA controller to use.  There are DMA controllers available at 0x500, 0x600, etc for the 6 DMA controllers on the board.  DMA controllers 0-3 can only be used with DMA request lines 0-3 and DMA controllers 4-5 can only be used with DMA request lines 4-5.  So, you'll want to choose the DMA channel for CDO_DMA_Select and a DMA controller that can be used together.

Then you only need to program the DMA request line with a call to tDMAChannel::config (  shown in aiex3.cpp as dma->config()  ).  If you choose to use DMA channels 4-5, you should be aware that there is a bug in the DMA library in tDMAChannel.cpp in this call (  _miteChannel->DeviceConfig.setReqSource ( 4 + _drq );  ).  It is correct for DMA channels 0-3, but for DMA channels 4-5 it should be (  _miteChannel->DeviceConfig.setReqSource ( _drq );  ).  In other words, the mapping for the DMA request source line and the value to write to DeviceConfig.setReqSource is:

  • DRQ0 4
  • DRQ1 5
  • DRQ2 6
  • DRQ3 7
  • DRQ4 4
  • DRQ5 5

This should hopefully be enough to guide you in the right direction.  I do not anticipate having time to create a full example of this for a while, but you can always request one here with a product suggestion.



Message Edited by Tom W [DE] on 05-07-2008 11:15 AM
Tom W
National Instruments
0 Kudos
Message 2 of 3
(6,993 Views)
Hi Tom- The informations are okay. DMA controller dedicated to moving data from the system memory to the CDO waveform generation is working fine now. Thanks very much for the help Imer.
0 Kudos
Message 3 of 3
(6,947 Views)