Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

S series DMA

Hi,
I try to use PCI-6143 card under Qnx. I download  DDK files. In the driver of the PCI 6143 , polling read implementation has been done. but i want to use DMA.
For this purpose, i add following function to the shipping polling read example.When i debugging, all functions return kNoError  status but when i try to read i see no data.
Please help, what's wrong
 
 
 tDMAError status = kNoError;  
    //
    // Specify DMA and user buffer sizes
    //
    const u32 dmaSizeInSamples = 100;
    const u32 dmaSizeInBytes   = dmaSizeInSamples * sizeof(i32);
    const u32 userSizeInSamples = 10;
    const u32 userSizeInBytes   = userSizeInSamples * sizeof(i32);
    //
    // DMA objects
    //
    tAddressSpace bar0;
    tMITE       *mite;
    tDMAChannel *dma;
    bar0 = bus->createAddressSpace(kPCI_BAR0);
    mite = new tMITE(bar0);
    mite->setAddressOffset(0x600);  
    dma = new tDMAChannel(bus, mite);
    //
    // Configure DMA on the device  
    //
    board->ScarabDMASelect.set(tSSeries::tScarabDMASelect::kChannel1);
    board->ScarabDMASelect.flush ();
    //
    // Configure and start DMA Channel
    status = dma->config (0, tDMAChannel::kRing, tDMAChannel::kIn, dmaSizeInBytes, tDMAChannel::k32bit);
     if (status != kNoError)
     {
         printf ("Error: dma configuration (%d)\n", status);
     }
   
    status = dma->start();
     if ( kNoError != status )
     {
         printf ("Error: dma start (%d)\n", status);
     }
     else
     {
         //
         // No error - arm and start AI engine
         //
        aiArm(theSTC); 
     aiStart(theSTC); // start acqusition
     }
   
    //
    // DMA Read
    //
   
0 Kudos
Message 1 of 16
(10,051 Views)

Hi eesen-

Your call to board->ScarabDMASelect is incorrect.  In order to setup DMA from scarab-based S Series devices you should set the DMA channel with a call to board->AIAO_Select.  Check out the attached file for an example of the steps required to enable the AI DMA engine.  This example is not specific to the 6143 (it's actually for another device), so your other device settings should remain unchanged; only the DMA content is necessarily applicable.

Hopefully this helps-

 

Tom W
National Instruments
0 Kudos
Message 2 of 16
(10,023 Views)

Thank you for your reply.

When i change DRQ source, i began to read data yesterday, but this time number of bytes available  is meaningless. Suddenly it becomes millions level altough i make sample at low rates. Todat i see yor reply and i think perhaps the reason of very high "number of bytes available" data  is calling wrong function.

 i don't understand why call board->ScarabDMASelect is incorrect. I can't do it by AIAO_Select since it doesn't have a method "set(dma channel)"  (maybe  i can't find. ) Can you be more especific, what method should i call exactly?

The example provided is not actually help me. Chip object  of 6133 provided by NI is different than 6143. There is no class named scab in 6143 chip objects. And in the example of 6133 ,most configuration about DMA is done by scrabe class method. I cant't find matching function on the 6143 side.

 

 

 

0 Kudos
Message 3 of 16
(10,013 Views)
hi again,
i achieve to transfer data with DMA.
I used board->AIAO_select->write(1) function to configure DMA. I hope its correct function.
I haven't make performance or correctness test yet, i just transfer.

I need a continuous dma read, but as far as i see, there is no implementation for it.Actually the missing part is a circular DMA buffer to use for continuous mode. Do you have a circular DMA buffer example?
Lastly, What is the difference between normal mode and ring mode?
0 Kudos
Message 4 of 16
(10,006 Views)
 

Hi eesen-

The ScarabDMASelect() bitfield is used to determine which DMA channel to use while downloading the large scarab image on scarab-based boards.  It does not apply to AI operations.  The AIAO_select bitfield is indeed the correct entry to indicate the AI DMA channel in use.  Possible values for AIAO_select are as follow (from the E Series RLP manual):

AI AO Select Register

The AI AO Select Register contains 8 bits that control the logical DMA selection for the

analog input and analog output resources. The contents of this register are cleared upon power

up and after a reset condition.

<...>

 

 

 

3–0 Input <D..A> Analog Input Logical Channel D through A—These four

 

bits select the logical channels to be used by the analog

input. You can only set one of these bits at a time.

 

In order to achieve a circular buffered DMA operation you should use Ring mode; it is the easiest to work with and works well with the MHDDK DMA library.  I don't have an example specific to the 6143, but the M Series example should be quite similar in terms of the steps to setup buffers and the actual access into the MHDDK DMA library.  Check out aiex3 from the M Series DDK as an example.

Hopefully this helps

Tom W
National Instruments
Message 5 of 16
(9,994 Views)

Hi,

I'm sorry for still bothering you.

I look at code of DDK and i see that wheather you choose normal mode or ring mode it create a linear DMAbuffer. I still don't understand difference between normal mode and ring mode.? What actually i need is continuous mode, i mean when i start dma it should continue transfer data till i stop it.Is ring mode  continuous mode?

Another problem is that, sometimes readidx become higher that writeidx, when this happen the number of bytes available= writeidx-readidx become a high number and code gives bufferoverflow error. It's nothing with to bufferoverflow.  how this can be happen i don't understand.

Thanks

0 Kudos
Message 6 of 16
(9,987 Views)

hi,

i solve writeidx , readidx issues by using getbytesinbuffer function in the following thread

http://forums.ni.com/ni/board/message?board.id=90&message.id=899&view=by_date_ascending&page=2

I have one l(hopefully last) problem.. How i choose dma channel, (i didn'nt do any adjustment,  i work with default channel???)a nd how i assign them to anolog input channel.As far as i know PCI 6143 has three DMA channel. I want to make such a configuration (for example)

sample data coming from analog input channel 0-2 will be transfered with DMA channel 0,

                                           analog input channel 3-5 will be transfered with DMA channel 1

                                           analog input channel 6,7 will be transfered with DMA channel 2

          

 

0 Kudos
Message 7 of 16
(9,975 Views)

Hi eesen-

In order to adjust the DMA channel in use you only need to make sure that the channel selected by the AIAO_Select bitfield and the channel number in dma->config() are the same.  Ring mode is indeed the preferred mode for continuous DMA using the MHDDK.

Glad to hear you're having better luck-

Tom W
National Instruments
0 Kudos
Message 8 of 16
(9,970 Views)
hi again,
i'm continue to work with DMA. I can do DMA transfer as i said before, but now i have perormance problems. I made a rough measurement. I measure time need for read function used by polling method and DMA method. What i expected is that DMA read shows a better performance than polling read. I do measurement as following

for DMA
// after i check even there is enough available data
get time()
dma->read()
get time
measuredtime=difference

for polling read
// after i check even there is available data
get time()
board>AIFifoData6143.readRegister()
get time
measuredtime=difference

The results are
dma read takes 7usec
poll method read takes 0,11 usec

Is my method is incorrect?
or perhaps there is problem in DMA driver
0 Kudos
Message 9 of 16
(9,918 Views)
hi again,
i'm continue to work with DMA. I can do DMA transfer as i said before, but now i have perormance problems. I made a rough measurement. I measure time need for read function used by polling method and DMA method. What i expected is that DMA read shows a better performance than polling read. I do measurement as following

for DMA
// after i check even there is enough available data
get time()
dma->read()
get time
measuredtime=difference

for polling read
// after i check even there is available data
get time()
board>AIFifoData6143.readRegister()
get time
measuredtime=difference

The results are
dma read takes 7usec
poll method read takes 0,11 usec

Is my method is incorrect?
or perhaps there is problem in DMA driver
0 Kudos
Message 10 of 16
(9,919 Views)