User manual

Appendix F DMA Programming Examples
VXI-MXI-2 User Manual F-6 © National Instruments Corporation
This example adds code to make use of the DMA interrupt
functionality on the VXI-MXI-2. Using the interrupt to determine when
a DMA operation is complete can improve performance over the
polling method described in Example 1 because the read cycles used to
poll CHSRx will be using bandwidth on whichever bus (VMEbus or
MXIbus) the host is located. The bandwidth the host is using to poll
CHSRx will not be available to the VXI-MXI-2 module’s DMA
controller. Using the DMA interrupt alleviates this problem since the
host is not required to poll. Because the DMA interrupt is common
between the two DMA controllers, you must be especially careful to
ensure that no interrupts are lost when both DMA controllers are
running. This example demonstrates how this can be achieved even
though only one DMA controller is being used in the example.
/************************************************************
* *
* Initialization: This section needs to be executed only *
* once prior to any DMA activity and does not have to be *
* repeated for each DMA operation. *
* *
***********************************************************/
/* The following write causes any block transfer to the MXIbus
from either DMA controller to be a synchronous burst transfer by
setting both DMAxMBS bits in the SMCR. You can modify this write
so that both DMA controllers perform normal MXIbus block
transfers, or you can have one DMA controller perform normal
MXIbus block transfers and the other perform synchronous burst
transfers. Remember that MXIbus synchronous burst transfers cannot
be used when both the source and destination are located on the
MXIbus. */
write(A24, A24BASE + SMCR, BYTE, 0x38);
/* The following write is required to initialize the CHCRx for the
DMA controller that will be used. Notice that the DONE interrupt
condition is being enabled here but the overall DMA interrupt for
this controller is not being enabled yet. This is because the DMA
controller is already in the DONE state on power up. The DMA
interrupt for the controller being used will be enabled after
starting the operation because the DONE condition will then be
clear until the operation is complete. If you will be using both
DMA controllers you should perform this write to both CHCR1 and
CHCR2. */
write(A24, A24BASE + CHCR1, LONGWORD, 0x02004000);