Using the Memory Access Resource

From Agilent VISA.NET

Using the Memory Access Resource

For VISA 1.1 and later, the Memory Access (MEMACC) resource type has been added to VXI and GPIB-VXI. VXI::MEMACC and GPIB-VXI::MEMACC allow access to all of the A16, A24, A32, and A64 memory by providing the controller with access to arbitrary registers or memory addresses on memory-mapped buses.

The MEMACC resource, like any other resource, starts with the basic operations and attributes of other VISA resources. For example, modifying the state of an attribute is done via the operation viSetAttribute.

Memory I/O Services

Memory I/O services include high-level memory I/O services and low-level memory I/O services.

High-Level Memory I/O Services

High-level memory I/O services allow register-level access to the interfaces that support direct memory access, such as the VXIbus, VMEbus, MXIbus, or even VME or VXI memory through a system controlled by a GPIB-VXI controller. A resource exists for each interface to which the controller has access.

You can access memory on the interface bus through operations such as viIn16 and viOut16. These operations encapsulate the map/unmap and peek/poke operations found in the low-level service. There is no need to explicitly map the memory to a window.

Low-Level Memory I/O Services

Low-level memory I/O services also allow register-level access to the interfaces that support direct memory access. Before an application can use the low-level service on the interface bus, it must map a range of addresses using the operation viMapAddress.

Although the resource handles the allocation and operation of the window, the programmer must free the window via viUnMapAddress when finished. This makes the window available for the system to reallocate.

Sample: MEMACC Resource Program

The peek16.c sample program demonstrates one way to use the MEMACC resource to open the entire VXI A16 memory and then calculate an offset to address a specific device.

MEMACC Attribute Descriptions

Generic MEMACC Attributes

The following read-only attributes (VI_ATTR_TMO_VALUE is read/write) provide general interface information.

Attribute

Description

VI_ATTR_INTF_TYPE

Interface type of the given session.

VI_ATTR_INTF_NUM

Board number for the given interface.

VI_ATTR_TMO_VALUE

Minimum timeout value to use, in milliseconds. A timeout value of VI_TMO_IMMEDIATE means operation should never wait for the device to respond. A timeout value of VI_TMO_INFINITE disables the timeout mechanism.

VI_ATTR_INTF_INST_NAME

Human-readable text describing the given interface.

VI_ATTR_DMA_ALLOW_EN

Specifies whether I/O accesses should use DMA (VI_TRUE) or Programmed I/O (VI_FALSE).

VXI, GPIB-VXI, and PXI-Specific MEMACC Attributes

The following attributes, most of which are read/write, provide memory window control information.

Attribute

Description

VI_ATTR_SRC_INCREMENT

Used in viMoveInxx operation to specify how much the source offset is to be incremented after every transfer. The default value is 1 and the viMoveInxx operation moves from consecutive elements.

 

If this attribute is set to 0, the viMoveInxx operation will always read from the same element, essentially treating the source as a FIFO register.

VI_ATTR_DEST_INCREMENT

Used in viMoveOutxx operation to specify how much the destination offset is to be incremented after every transfer. The default value is 1 and the viMoveOutxx operation moves into consecutive elements.

 

If this attribute is set to 0, the viMoveOutxx operation will always write to the same element, essentially treating the destination as a FIFO register.

VI_ATTR_WIN_ACCESS

Specifies modes in which the current window may be addressed: not currently mapped, through the viPeekxx or viPokexx operations only, or through operations and/or by directly de-referencing the address parameter as a pointer.

VI_ATTR_WIN_BASE_ADDR_32

Base address of the interface bus to which this window is mapped.

VI_ATTR_WIN_BASE_ADDR_64

Base address of the interface bus to which this window is mapped.

VI_ATTR_WIN_SIZE_32

Size of the region mapped to this window.

VI_ATTR_WIN_SIZE_64

Size of the region mapped to this window.

VXI and GPIB-VXI-Specific MEMACC Attributes

The following attributes, most of which are read/write, provide memory window control information

Attribute

Description

VI_ATTR_VXI_LA

Logical address of the local controller.

VI_ATTR_SRC_BYTE_ORDER

Specifies the byte order used in high-level access operations, such as viInxx and viMoveInxx, when reading from the source.

VI_ATTR_DEST_BYTE_ORDER

Specifies the byte order used in high-level access operations, such as viOutxx and viMoveOutxx, when writing to the destination.

VI_ATTR_WIN_BYTE_ORDER

Specifies the byte order used in low-level access operations, such as viMapAddress, viPeekxx, and viPokexx, when accessing the mapped window.

VI_ATTR_SRC_ACCESS_PRIV

Specifies the address modifier used in high-level access operations, such as viInxx and viMoveInxx, when reading from the source.

VI_ATTR_DEST_ACCESS_PRIV

Specifies the address modifier used in high-level access operations, such as viOutxx and viMoveOutxx, when writing to the destination.

VI_ATTR_WIN_ACCESS_PRIV

Specifies the address modifier used in low-level access operations, such as viMapAddress, viPeekxx, and viPokexx, when accessing the mapped window.

GPIB-VXI-Specific MEMACC Attributes

The following read-only attributes provide specific address information about GPIB hardware.

Attribute

Description

VI_ATTR_INTF_PARENT_NUM

Board number of the GPIB board to which the GPIB-VXI is attached.

VI_ATTR_GPIB_PRIMARY_ADDR

Primary address of the GPIB-VXI controller used by the session.

VI_ATTR_GPIB_SECONDARY_ADDR

Secondary address of the GPIB-VXI controller used by the session.

MEMACC Resource Event Attribute

The following read-only events provide notification that an asynchronous operation has completed.

Attribute

Description

VI_ATTR_EVENT_TYPE

Unique logical identifier of the event.

VI_ATTR_STATUS

Return code of the asynchronous I/O operation that has completed.

VI_ATTR_JOB_ID

Job ID of the asynchronous I/O operation that has completed.

VI_ATTR_BUFFER

Address of a buffer used in an asynchronous operation.

VI_ATTR_RET_COUNT

Actual number of elements that were asynchronously transferred.