Using the Memory Access Resource

This section contains information specific to the Windows product.

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

Attribute Value

Description

VI_ATTR_INTF_TYPE

0x3FFF0171UL

Interface type of the given session.

VI_ATTR_INTF_NUM

0x3FFF0176UL

Board number for the given interface.

VI_ATTR_TMO_VALUE

0x3FFF001AUL

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

0xBFFF00E9UL

Human-readable text describing the given interface.

VI_ATTR_DMA_ALLOW_EN

0x3FFF001EUL

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

Attribute Value

Description

VI_ATTR_SRC_INCREMENT

0x3FFF0040UL

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

0x3FFF0041UL

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

0x3FFF00C3UL

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

0x3FFF0098UL

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

VI_ATTR_WIN_BASE_ADDR_64

0x3FFF009BUL

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

VI_ATTR_WIN_SIZE_32

0x3FFF009AUL

Size of the region mapped to this window.

VI_ATTR_WIN_SIZE_64

0x3FFF009CUL

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

Attribute Value

Description

VI_ATTR_VXI_LA

0x3FFF00D5UL

Logical address of the local controller.

VI_ATTR_SRC_BYTE_ORDER

0x3FFF003DUL

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

0x3FFF003AUL

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

0x3FFF0047UL

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

0x3FFF003CUL

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

0x3FFF0039UL

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

0x3FFF0045UL

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

Attribute Value

Description

VI_ATTR_INTF_PARENT_NUM

0x3FFF0101UL

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

VI_ATTR_GPIB_PRIMARY_ADDR

0x3FFF0172UL

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

VI_ATTR_GPIB_SECONDARY_ADDR

0x3FFF0173UL

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

Attribute Value

Description

VI_ATTR_EVENT_TYPE

0x3FFF4010UL

Unique logical identifier of the event.

VI_ATTR_STATUS

0x3FFF4025UL

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

VI_ATTR_JOB_ID

0x3FFF4006UL

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

VI_ATTR_BUFFER

0x3FFF4027UL

Address of a buffer used in an asynchronous operation.

VI_ATTR_RET_COUNT

32-bit: 0x3FFF4026UL

64-bit: 0x3FFF4028UL

Actual number of elements that were asynchronously transferred.