Chapter 2 Function Reference — Align_DMA_Buffer
©
National Instruments Corporation 2-23 NI-DAQ FRM for PC Compatibles
buffer is the integer array of samples NI-DAQ uses in the waveform or pattern generation.
The actual size of buffer should be larger than the number of samples to make room for
possible alignment. If the actual size of the buffer is not big enough for alignment, the
function returns a memAlignmentError. For Windows applications running in real or
standard mode, a bufferSize of 2
*
count guarantees that there is enough room for alignment.
count is the number of data samples contained in buffer.
Range: 3 through 2
32
– 1.
bufferSize is the actual size of buffer.
Range: count through 2
32
–1.
alignIndex is the variable in which NI-DAQ returns the offset into the array of the first
data sample. If NI-DAQ did not have to align the buffer, NI-DAQ returns alignIndex as 0,
indicating that the data is still located at the beginning of the buffer. If NI-DAQ aligned the
buffer to avoid a page boundary, alignIndex is a value other than 0, and the first data sample
is located at buffer[alignIndex] (if your array is zero based). If you use digital input with an
aligned buffer, NI-DAQ stores the data in the buffer beginning at alignIndex.
Note C Programmers—alignIndex is a pass-by-reference parameter.
Using This Function
Use Align_DMA_Buffer to avoid the negative effects of page boundaries in the data buffer
on AT bus machines for the following cases:
• DMA waveform generation at close to maximum speed
• Digital I/O pattern generation at close to maximum speed
• Interleaved DMA waveform generation at any speed
• 32-bit digital I/O pattern generation at any speed
The possibility of a page boundary occurring in the data buffer increases with the size of the
buffer. When a page boundary occurs in the data buffer, NI-DAQ must reprogram the DMA
controller before NI-DAQ can transfer the next data sample. The extra time needed to do the
reprogramming increases the minimum update interval (thus decreasing the maximum update
rate).
A page boundary in an interleaved DMA waveform buffer or a buffer that is to be used for
32-bit digital pattern generation can cause unpredictable results, regardless of your operating
speed. To avoid this problem, you should always use
Align_DMA_Buffer with interleaved
DMA waveform generation (indicated by resource = 2) and 32-bit digital pattern generation
(indicated by resource = 13). In these two cases,
Align_DMA_Buffer first attempts to align
the buffer so that the data completely avoids a page boundary. If bufferSize is not big enough
for complete alignment, the function attempts to partially align the data to ensure that a
page boundary does not cause unpredictable results. Partial alignment is possible if