Справочник Пользователя для National Instruments NI-VXI

Скачать
Страница из 149
Chapter 2        Introduction to the NI-VXI Functions
NI-VXI User Manual
2-14
© National Instruments Corporation
  Master Memory Access
You can access VXIbus memory directly through the NI-VXI
high-level and low-level VXIbus access functions, within the
capabilities of the controller. The main difference between the
high-level and low-level access functions is in the amount of
encapsulation given by NI-VXI.
The high-level VXIbus access functions include functions such as
VXIin()
 and 
VXImove()
 that you can use to access memory in the
VXI system without dealing with such details as memory-mapping
windows, status checking, and recovering from bus timeouts. Although
these functions tend to have more overhead associated with them than
the low-level functions, they are much simpler to use and typically
require less debugging. We recommend that beginner programmers in
VXI rely on the high-level functions until they are familiar with VXI
memory accesses.
You can use the low-level VXI/VMEbus access functions if you want
to access VXI/VME memory with as little overhead as possible.
Although you now have to perform such actions as bus error handling
and mapping—which are handled automatically by the high-level
functions—you can experience a performance gain if you optimize for
the particular accesses you are performing. Consider the following
sample code, which performs a memory access using the low-level
functions. Notice that there is no bus error handler installed by the
program (See the Interrupts and Signals section). Instead, the program
uses the NI-VXI default bus error handler. This handler automatically
increments the 
BusErrorRecv
 global variable.
C/C++ Example:
#include <nivxi.h>
/* BusErrorRecv defined in nivxi.h */
#include <stdio.h>
main() {
INT16 ret, la;
UINT16 *addrptr, svalue;
UINT32 addr, window1;
INT32
timeout;
UINT32 addrptr1;
/* Start all programs with this function */
ret = InitVXIlibrary();
BusErrorRecv = 0;
/* Reset global variable */
/* The following code maps the A16 space with the Access Only */
/* access in order to access the A16 space directly.  */
addr = 0xc000L;  /* Map upper 16 KB of the A16 space */