01-16-2018 03:47 PM
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
Solved! Go to Solution.
01-31-2018 12:58 AM
Maybe there is an issue with the iBus::allocDMA function for QNX Neutrino?
02-01-2018 12:24 AM
The problem has been fixed by using the 64 bit versions of memory related functions mmap and mem_offset in osiUserCode for Neutrino 6.
02-01-2018 05:07 PM
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;
}