Chapter 4
Programming
©
National Instruments Corporation
4-17
12. The function
AI_Start_The_Acquisition
starts the acquisition
process.
AI_Command_2_Register
AI START1 Pulse = 1;
13. Poll the AI FIFO not empty flag in the AI_Status_1_Register until not
empty and call the ISR.
Do
{
If (AI FIFO not empty) then
call
Interrupt_Service_Routine
;
} while (20 samples have not been read)
Example 4
Example 4 performs the same acquisition as Example 2, but with DMA.
This example scans four channels 10 times using DMA to transfer data
from the AI FIFO. Acquire 10 scans with a scan interval of 1 ms. The scan
list contains channels 5, 4, 1, and 0, respectively, each at a gain of 1 and in
RSE mode. Within each scan, the sample interval should be 100 µs.
Dithering should remain off during the acquisition. Use DMA to transfer
data from the FIFO. The DMA controller puts the data into two different
buffers, each has a size of 40 bytes. This example constructs a linked list to
contain the information about the buffers, such as their physical address,
logical address and total transfer bytes. You need to pass the linked list head
node to
MITE_DMAProgram
to program the MITE.
Since the physical address calculation is only valid for real mode on a PC,
this example only runs under DOS. If you want to program DMA under
other operating systems, you must learn about the memory’s physical
address calculation and the usage of virtual memory. For example, if you
want to program DMA under Windows or Macintosh OS, make sure that
you lock the memory locations for DMA, so the virtual memory manager
cannot move the data from current physical memory location. This example
provides a basic outline for you to program the MITE for DMA transfers.
dma.c
contains the functions
MITE_DMAProgram
,
MITE_DMAarm
, and
MITE_DMAdisarm.
miteregb.h
contains the bit field assignment for the
MITE.
1.
Perform Analog Input Example 1 Step 1.
2.
Perform Analog Input Example 1 Step 2 for each channel in the scan
list. Only channel 0 has Last channel set to 1.
3.
Perform Analog Input Example 1 Steps 3-9.