National Instruments 370551A-01 用户手册

下载
页码 139
Chapter 7
Using the NI-VXI/NI-VISA Software
© National Instruments Corporation
7-3
Low-Level Access Functions
The memory windows used to access the VXI/VMEbus are a limited 
resource. You should follow the protocol of calling the 
viMapAddress()
 
or 
MapVXIAddress()
 function with Access Only mode first before 
attempting to perform low-level VXI/VMEbus access with 
viPeekX()
/
viPokeX()
 or 
VXIpeek()
/
VXIpoke()
. Your application 
should always call the 
viUnmapAddress()
 or 
UnMapVXIAddress()
 
function immediately after the accesses are complete so that you free up the 
memory window for other applications.
The functions 
viMapAddress()
 and 
MapVXIAddress()
 return a pointer 
for use with low-level access functions. It is strongly recommended that 
you use the functions to access the memory instead of directly 
dereferencing the pointer. Using these functions makes the NI-VXI/VISA 
software more portable between platforms. Refer to the 
 section for more information on portability 
issues, and to your NI-VXI or NI-VISA software reference manual for 
more information on low-level VXIbus or VMEbus access functions.
Local Resource Access Functions
By using 
vxiedit
, you can set up the PCI-MXI-2 to share either the 
system memory on the motherboard or the onboard memory on the 
PCI-MXI-2 with the VXI/VME system. Refer to the NI-VXI Graphical 
Utilities Reference Manual
 for more information on setting these 
parameters.
Notice that sharing the system memory with the VXI/VME system does not 
mean that the entire range of shared system memory is available to be used 
for VXI/VME transfers. You need to be cautious in specifying the portion 
of memory you want to share, as some areas are already used for other 
purposes.
Caution
Use 
viMemAlloc()
 or 
VXImemAlloc()
 to allocate a buffer in the system 
memory that is reserved for your use only. Using any range of addresses that was not 
returned from 
viMemAlloc()
 or 
VXImemAlloc()
 to receive data may cause your 
computer to crash or behave incorrectly.
The onboard memory on your PCI-MXI-2, on the other hand, is entirely 
available to you. You can obtain the VXI address of your onboard memory 
using the 
GetDevInfo()
 function. When you have the VXI/VME address, 
you can access that memory using high-level or low-level VXI/VMEbus 
access functions.