Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

6133 DMA samples all zero

Solved!
Go to solution

I have code (attached) derived from examples and past undocumented R&D for getting analog input data from the 6133 DAQ board via either register based I/O, or DMA. The register based I/O works. However, the DMA provides all zero samples. I would appreciate it if someone with more experience with the MHDDK can have a look at it.

Thanks.

 

Definitions used from outside the file provided are:

#define DAQ_SAMPLE_RATE 2000000

#define NUM_ADC_CHANNELS 2

#define ADC_RESOLUTION 14

#define END_OF_CONVERT_DELAY 17

#define SAMPLES_PER_REV 4000

#define NUM_CHANNELS 2

0 Kudos
Message 1 of 5
(2,675 Views)

Hi Sorterralee,

 

This the right place to ask for help on this subject: https://forums.ni.com/t5/Driver-Development-Kit-DDK/bd-p/90.

 

The forum is monitored by R&D according to this article: http://digital.ni.com/public.nsf/allkb/F4FEA84797FF1F2186256F6B005D8761.

Message 2 of 5
(2,648 Views)

Thanks for that. I now have added the topic to that forum. I will leave it here also, in the hope that someone seeing either forum will have an answer soon.

0 Kudos
Message 3 of 5
(2,645 Views)
Solution
Accepted by topic author Sorterralee

The problem has been fixed by using the 64 bit versions of memory related functions mmap and mem_offset in osiUserCode for Neutrino 6.

0 Kudos
Message 4 of 5
(2,597 Views)

ie. The fix is done in the function below, found in nimhddk/QNXNeutrino6/osiUserCode.cpp. Refer to lines in "#if NI6133_DMA_USE_MEM64"

 

tDMAMemory * iBus::allocDMA (u32 size)
{

    void *virtualAddress;
#if NI6133_DMA_USE_MEM64
    off64_t physicalAddress;
#else
    off_t physicalAddress;
#endif

    // Allocate DMA buffer
#if NI6133_DMA_USE_MEM64
    virtualAddress = mmap64( 0, // set target 0 means that the system can put it anywhere it wants
#else
    virtualAddress = mmap( 0, // set target 0 means that the system can put it anywhere it wants
#endif
    size,
    PROT_READ|PROT_WRITE|PROT_NOCACHE, // Can read, write. Should not be cached.
    MAP_PHYS|MAP_ANON, // Dealing with physical memory. With MAP_ANON means physical contiguous memory is allocated (required for DMA buffer).
    NOFD, // fd
    0 ); // offset within shared memory. "Common to map in an entire shared object, in which case offset will be zero"
    if (virtualAddress == MAP_FAILED)
    {
        munmap (virtualAddress, size);
        return NULL;
    }
    // Get physical adddress
#if NI6133_DMA_USE_MEM64
    if (mem_offset64( virtualAddress, NOFD, size, &physicalAddress, 0) == -1)
#else
    if (mem_offset( virtualAddress, NOFD, size, &physicalAddress, 0) == -1)
#endif
    {
        munmap (virtualAddress, size);
        return NULL;
    }
    tDMAMemory *dma = new tDMAMemory (virtualAddress, physicalAddress, size);
    if (NULL == dma)
    {
        munmap (virtualAddress, size);
    }

    return dma;
}

0 Kudos
Message 5 of 5
(2,582 Views)