Archived: Using NI-VXI Software for VMEbus Systems

Publish Date: Nov 17, 2016 | 4 Ratings | 3.75 out of 5 | Print | Submit your review

Overview

This document has been archived and is no longer updated by National Instruments.

This application note describes how you can use NI-VXI software to configure and program a VMEbus system. Sample programs are also included in this application note.

NI-VXI software was designed for VXI (VME eXtensions for Instrumentation) systems; NI-VXI software consists of functions and utilities for programming VXIbus systems using a variety of controller platforms and operating systems. Because VXI is based on VME, the same software can be used for configuring and programming VME systems.

Table of Contents

  1. VXI Background
  2. Configuring a VMEbus System with the NI-VXI Configuration Utilities
  3. Programming a VMEbus System with the NI-VXI Functions or Library
  4. Sample VMEbus System

1. VXI Background


The VXIbus specification details the technical requirements of VXIbus-compatible mainframes and plug-in modules, including packaging requirements, electromagnetic compatibility, power distribution, cooling, and airflow specifications. VXI modules must have a specific set of registers located at specific addresses. The upper 16 KB of the 64 KB Short (A16) address space are allocated for VXIbus devices. Each VXI device has a unique 8-bit logical address that specifies the location of its registers in this 16 KB address space. Using this addressing scheme, a single VXI system can include up to 256 VXI devices.

The VXIbus specification defines a Commander/Servant mapping mechanism so you can construct hierarchical systems using VXI devices. This structure is like an inverted tree. A Commander is any device in the hierarchy with one or more associated lower level devices (Servants). A Servant is any device in the subtree of a Commander. A device can be both a Commander and a Servant in a multilevel hierarchy.

All VXI systems require a system initialization program known as the VXI Resource Manager (RM). The RM executes on the VXI device at Logical Address 0, and is usually the top-level Commander in the hierarchy. The RM performs the following basic functions at power-up:

1. Initializes hardware interface between controller and VXI/VMEbus

2. Identifies each VXI device in the system

3. Assigns logical addresses to Dynamic Configuration devices

4. Configures Standard/Extended (A24/A32) memory space requirements

5. Establishes VXI Commander/Servant hierarchies

6. Initiates normal operation

In a VME system, the RM is needed only to initialize the hardware interface between the controller device and the VMEbus while taking into account Short, Standard, and Extended (A16/A24/A32) address space requirements. In a VXI system, the RM uses the VXI configuration registers to identify each VXI device, its device class, model and manufacturer, and memory requirements. All VXIbus device classes must have this minimal level of support. VXIbus devices with only this minimum level of capability are called Register-Based devices. Because VME devices do not have the standardized VXI register set, the information normally encoded in this VXI-defined register set must be manually entered for your VME devices before the RM can properly configure your interface hardware to the VMEbus.

VXI also defines devices called Message-Based devices. These devices are required to have a set of communication registers in addition to the configuration registers. A Message-Based device has a standardized message-passing protocol called Word Serial Protocol. The protocol is called word serial because communication with a Message-Based device is done by writing and reading 16-bit words, one at a time, to and from the Data In (write Data Low) and Data Out (read Data Low) hardware registers located on the device itself. The Response register of the device indicates whether the Data In register is empty and whether the Data Out register is full. Word Serial Protocol is VXIbus specific. Because VME systems do not implement this protocol, they cannot use the NI-VXI Word Serial functions provided for Word Serial communication.

VXI systems have two ways for devices to communicate status and events asynchronously to other devices. One method involves a modified version of the traditional VME hardware interrupts. Alternatively, they can write specific messages (VXI signals) directly to the hardware Signal register (a register defined by VXI) of the other device. VXI devices that have bus-master capabilities can either use interrupts or send VXI signals, whereas VXI devices without this capability always transmit such information through interrupts only. The interrupt acknowledge cycle in a VXI system returns a 16-bit status/ID value. The lower 8 bits of a VXI status/ID value form the logical address of the interrupting device. The upper 8 bits specify a status/event as defined in the VXIbus specification.

Whereas a VXI system uses a 16-bit interrupt status/ID value, the VME interrupt acknowledge cycle in a VME system usually returns an 8-bit status/ID value. Most 680X0-based VME CPUs route this 8-bit value directly to the 680X0 processor as a local interrupt vector value. In other words, this value directly determines which interrupt service routine to invoke. In VXI systems, however, the interrupt status/ID value is considered as data rather than as a vector, because the status/ID value specifies the nature of the interrupt rather than the location of the interrupt service routine. For this reason, the NI-VXI interrupt handling routines do not use the status/ID value as a vector, but instead decouple the status/ID value so that the interrupt service routine can treat it as data. You can install interrupt service routines in the NI-VXI environment that can handle any status/ID on any level. Your interrupt service routine can then use the status/ID value as data. VME systems do not need to use the NI-VXI Signal functions, because VME devices communicate asynchronous events via VME interrupts and not through VXI signals. VME systems also have no need for the functions that map VME interrupts as VXI signals in the NI-VXI Interrupt functions group.

VXI triggers are a backplane feature that VXI added to the VME standard. Every VXI device with a P2 connector has access to eight 10 MHz TTL trigger lines. VXI devices with a P3 connector have access to six 100 MHz ECL trigger lines. The NI-VXI Trigger functions are useful for sourcing, accepting and mapping all appropriate TTL and ECL VXI trigger lines. These functions are VXI-specific and are not used in VME systems.

Back to Top

2. Configuring a VMEbus System with the NI-VXI Configuration Utilities



NI-VXI software includes the following utility programs that you can use to configure a VME system:

  • T&M Explorer -- use it to edit your system configuration. The Add Device... Wizard in the Edit menu includes an option you can use to add a VME device to the configuration.
  • Resman -- the National Instruments multiframe Resource Manager program that automatically configures the VME system with one or more interconnected VME mainframes, based on the information provided in T&M Explorer.
  • VIC -- the VXI Interactive Control program. VIC is a multipurpose program you can use to learn the NI-VXI function calls, communicate with devices, troubleshoot problems, and develop your applications.


The Add Device Wizard in T&M Explorer walks you through the process of adding a VMEbus device to your system. Each VME device requires a pseudo-logical address (pseudo-LA), ranging from 256 to 511. NI-VXI uses the pseudo-logical address to smoothly integrate the VME device into the VXI system.

After choosing a pseudo-LA and specifying the frame and slot in which the device is located, click Next and specify a name, manufacturer, and model for the device.

If you wish, you can add information for numerous VME devices, and use the Device Enabled check-box in the device Properties window (accessed from the View menu, or by right-clicking the device in the view window) to specify whether that device is physically in the system. In this way you can maintain a "database" of VME devices. Keep in mind that the resource manager uses only the configuration information for those devices that you indicate as being enabled.

When the RM executes, it uses the information you specified when you added the VME device to allocate resources for that device. You can use the Properties window to change this information; rerunning the resource manager will reallocate the resources appropriately.

To access a VME device (for example, to get information with the GetDevInfo function), your application should use the pseudo-LA assigned to that VME device.

As an alternative to giving detailed information for each VME device in your system, you can provide the information collectively by considering the overall resource requirements of your VME devices as one logical VME device.

After you configure the VME system, use the VXI Interactive Control program (VIC) to communicate with devices in the VME system and verify that the VME system is configured properly. You can then proceed to use the NI-VXI driver software to develop application programs for the VME system.

Back to Top

3. Programming a VMEbus System with the NI-VXI Functions or Library



The following paragraphs describe the function groups that are applicable for programming in a VME system.

  • System Configuration Functions

    The System Configuration functions provide the lowest level initialization of your VME interface. You must use the InitVXIlibrary function at the start of each application and the CloseVXIlibrary function at the end of each application. If you choose, you can use the System Configuration functions GetDevInfo and SetDevInfo to retrieve and modify device configuration information.

  • Low-Level VMEbus Access Functions

    Low-Level VMEbus access is the fastest access method for directly reading from or writing to any of the VMEbus address spaces. You can use the MapVXIAddress function to obtain a pointer that is directly mapped to a particular VMEbus address with a particular privilege mode. How the pointer is used is at the discretion of the application. You should take into account certain programming constraints and error conditions such as Bus Error (BERR*) when using these functions.

  • High-Level VMEbus Access Functions

    The High-Level VMEbus Access functions are similar to the Low-Level VMEbus Access functions insofar as they give you direct access to the VMEbus address spaces. You can use the VXIin function to read, VXIout to write, and VXImove to move blocks of data between any of the VMEbus address spaces. You can specify any VMEbus privilege mode. Bus Errors are trapped and reported. When the execution speed is not a critical issue, you may prefer the High-Level VMEbus Access functions for their easy-to-use interface.

  • Interrupt Functions

    The NI-VXI Interrupt functions are used to handle VME interrupters. In VME, a device asserts a VME interrupt line and the VME interrupt handler device acknowledges the interrupt. During the VME interrupt acknowledge cycle, an 8-bit status/ID value is returned. On most 680X0-based VME CPUs, this 8-bit value is routed directly to the 680X0 processor as a local interrupt vector value. With NI-VXI, however, you do not have to worry about making sure that the 8-bit interrupt status/ID value returned from a device corresponds to the address of an interrupt service routine. You can set the 8-bit interrupt status/ID value for your devices to any value you want to use. Use the NI-VXI Interrupt function SetVXIintHandler to install an interrupt service routine for a particular VME interrupt level. The NI-VXI interrupt handler routine traps the VME interrupt, performs the interrupt acknowledge cycle, and calls the user-installed interrupt service routine associated with that particular VME interrupt level. The status/ID value is given directly to the user-installed interrupt service routine and can be interpreted to suit your needs. For example, if you have two interrupters that share the same interrupt level, you would install one interrupt handler routine for that level. The interrupt handler routine itself would examine the status/ID value to determine which of the two devices caused the interrupt. The interrupt status/ID values for your VME devices can be any value you choose. However, it is recommended that multiple devices sharing a single interrupt line use unique interrupt status/ID values so that your interrupt service routine can use these values to determine which device is interrupting. The Interrupt functions EnableVXIint and DisableVXIint sensitize and desensitize your application program to VME interrupts routed to your VME interrupt service routines.

    As mentioned previously, the NI-VXI Interrupt functions can process individual interrupt status/ID values in a VXI system either as traditional VME interrupt status/IDs or as VXI signals. By default, the NI-VXI functions process status/IDs as VXI signals. For a VME system, you need to call the RouteVXIint function to specify that the NI-VXI interrupt handler routine process the status/IDs as traditional VME status/IDs rather than as VXI signals.

    In VME, the two types of interrupters are the release-on-acknowledge (ROAK) and the release-on register-access (RORA) interrupters. An ROAK interrupter automatically deasserts the VME interrupt line it is asserting when an interrupt acknowledge cycle on the VME backplane occurs on the corresponding level. A RORA interrupter continues to assert the VME interrupt line even after the interrupt acknowledge cycle is completed. It deasserts the VME interrupt only in response to some device-specific interaction. Because a RORA interrupt remains asserted on the VME backplane, the local CPU interrupt generation must be inhibited until the device-dependent interaction is complete. Use the VXIintAcknowledgeMode function to specify whether a VME interrupt level for a particular controller (embedded or extended) is to be handled as a RORA or ROAK interrupt. If you specify it as a RORA interrupt, the local CPU automatically inhibits the corresponding lines from generating VME interrupts whenever the corresponding VME interrupt occurs. After your application program has handled and caused the RORA interrupter to deassert the interrupt line, remember to call EnableVXIint to restore the ability of the local CPU to recognize and handle interrupts on that particular interrupt line.

  • System Interrupt Handler Functions

    Use the System Interrupt Handler functions to install interrupt service routines for the system interrupt conditions. These conditions include Sysfail, ACfail, and Bus Error.

    Back to Top

    4. Sample VMEbus System


This section shows how to use the NI-VXI software to configure and program a sample VMEbus system.

Configuring the Sample VMEbus System
The sample VME system consists of the following components:

  • A computer with a MXIbus-based VME interface kit. The kit includes a MXI interface board for the computer, a VME-MXI interface board for the VME chassis, an interconnecting MXI cable, and NI-VXI software to run on the computer.
  • A VME data acquisition board installed in the VME chassis with 4 KB of memory in Standard (A24) space at address 0x800000
  • Two VME devices that require no VME addresses but that are both ROAK VME interrupters interrupting on VME interrupt level 2 with status/ID interrupt vector values of 0x80 and 0x90, respectively


Follow these steps to configure the sample VME system.

1. Run T&M Explorer and run the Add Device... Wizard. Choose VME Device and click Next.



2. Assign the VME data acquisition board a pseudo-logical address between 256 and 511 along with a device, manufacturer, and model name, as well as the frame and slot number where the device is located.

3. Set the Standard (A24) memory base of the VME data acquisition board to 0x800000 and its size to 0x1000.

4. Select Finish to add the device to your system.

5. Select Properties from the View menu and ensure that the device is enabled. The first VME device has now been added to the system.

6. To add the second device -- one of the VME interrupters -- run the Add Device... Wizard again. Assign this VME interrupter a unique pseudo-logical address and a device, manufacturer, and model name, as well as the frame and slot number where the device is located.

7. Set the interrupt line used to 2.

8. Save this information.

9. Ensure that the device is enabled.

10. Repeat steps 6 through 9 for the second VME interrupter.

11. Run the RM to automatically configure the system. Verify that the RM display reflects all three VME devices in your system.

After you configure the VME system, run VIC to verify that you can successfully communicate with devices in the VME system. You can use vxiin/vxiout commands in VIC to peek/poke memory on the VME memory card in the sample system. After verifying that the VME system is configured properly, you can proceed with the following example programs for the sample VME system.

Programming the Sample VMEbus System
The first two example programs show how you can use the NI-VXI High-Level and Low-Level VMEbus Access functions to move data from the VME data acquisition board’s memory into a local buffer.

The third example shows you how you can use the NI-VXI Interrupt functions for handling the VME interrupt from the two interrupter devices in the VME system.

The following parameter types used in the examples make these examples completely portable among various operating systems and target CPUs supported by the NI-VXI software.

  typedef  int8    char            /* 8-bit signed int.    */
  typedef  uint8   unsigned char   /* 8-bit unsigned int.  */
  typedef  int16   short           /* 16-bit signed int.   */
  typedef  uint16  unsigned short  /* 16-bit unsigned int. */
  typedef  int32   long            /* 32-bit signed int.   */
  typedef  uint32  unsigned long   /* 32-bit unsigned int. */

These types are automatically defined when you include the header file nivxi.h at the beginning of the following programs.

/***********************************************************/
/*                                                         */
/*             High Level VMEbus Access Example            */
/*              (c) 1991, National Instruments             */
/*                                                         */
/* This example shows how you can use the NI-VXI High-     */
/* Level VMEbus Access functions to move data from the VME */
/* data acquisition board’s Standard (A24) memory into a   */
/* local buffer.                                           */
/***********************************************************/
#include <stdio.h>
#include "nivxi.h"


main()
{
   int16   retval;
   uint16  srcparms;
   uint32  srcaddr;
   uint16  destparms;
   uint32  destaddr;
   uint32  length;
   uint16  width;


      /* Initialize the NI-VXI software at the start of */
         the application.      */
   if (InitVXIlibrary() < 0)
    {
         /* Error in InitVXIlibrary */
      printf("InitVXIlibrary failed.  Unable to continue\n");
      exit(0);
    }


   length = 0x800L;      /* 2 K transfers */
   width = 2;            /* Transfer as words */
       /* Standard (A24) space, Non-Priv.Data, Motorola */
          byte order */
   srcparms = 2;
   srcaddr = 0x800000;   /* Base address of the data */
          acquisition board */
   destparms = 0;        /* Local space */
   destaddr = (uint32) malloc(length*width);      
       /* Allocate local memory */
   retval = VXImove(srcparms, srcaddr, destparms, destaddr, 
   length, width);
    if (retval != 0)
    {
       printf("VXImove failed with the return code = %hd\n",
      retval);

    }


    /*


   Process data in the buffer


    */


   free((int8 *)destaddr);      /* Free the allocated
                                  local memory. */

   retval = CloseVXIlibrary();  /* Close the NI-VXI
                                  software. */

    }

/***********************************************************/
/*                                                         */
/*              Low Level VMEbus Access Example            */
/*              (c) 1991, National Instruments             */
/*                                                         */
/* This example shows how you can use the NI-VXI Low-Level */
/* VMEbus Access functions to move data from the VME data  */

/* acquisition board’s Standard (A24) memory into a local  */
/* buffer.                                                 */

/*                                                         */
/***********************************************************/
#include <stdio.h>
#include "nivxi.h"


uint32 BusErrorHandlerFlag = 0L; /* Global Bus Error count */



void ExampleBusErrorHandler()  /* Sample Bus Error 
                                  interrupt handler */
{
   BusErrorHandlerFlag++;
}


main()
{
   uint16   *addr;
   uint16   accessparms;
   uint32    address;
   uint32    timeout;
   uint32    window;
   int16     retval;
   uint32   count;
   uint16    *buffer;


   /* Initialize the NI-VXI software at the start of 
      the application.   */
   if (InitVXIlibrary() < 0)
    {
         /* Error in InitVXIlibrary */
      printf("InitVXIlibrary failed.  Unable to continue\n");
      exit(0);
    }


      /* Install sample Bus Error handler. Whenever there
     is a bus error, the function ExampleBusErrorHandler
     is executed. */

   SetBusErrorHandler(ExampleBusErrorHandler);


   accessparms = 0;      /* Standard space, Non-Priv. Data,
                           Motorola byte order, Access Only
                           Privileges */

   address = 0x800000;   /* Base address of the data
                           acquisition board */

   timeout = 5000L;      /* Timeout of 5 seconds */
   addr=(uint16 *)MapVXIAddress(accessparms, address,
        timeout, &window, &retval);

   if (retval == 0)      /* MapVXIAddress was successful. */
    {
      buffer = (uint16 *) malloc(0x1000);   /* Allocate
                                           local memory. */

       for(count=0;count<0x800;count++)
          VXIpeek(addr++, 2, buffer++);


       /*


         Process the data in the buffer


       */
      free((int8 *)buffer);     /* Free the local memory. */
      retval = UnMapVXIAddress(window); /* Unmap pointer. */
    }
   else
    {
       /*
         Error in MapVXIAddress
       */
    }


      /* Close the NI-VXI software at the end. */
   retval = CloseVXIlibrary();
}

/***********************************************************/
/*                                                         */
/*               NI-VXI VME Interrupt Example              */
/*             (c) 1991, National Instruments              */
/*                                                         */
/* This example shows how you can use the NI-VXI interrupt */
/* functions for handling the VME interrupt from           */
/* interrupter devices in the sample VME  system.          */
/***********************************************************/
#include <stdio.h>
#include "nivxi.h"


uint16   levels = 0; /* Global variable containing levels
                       enabled/disabled */

uint16   Sroute = 0; /* Global variable containing route
                       information */

uint16   modes = 0;  /* Global variable containing ROAK/RORA
                       modes */




void ExampleVMEintHandler(controller, level, statusID)
int16    controller;
uint16    level;
uint32   statusID;
{
   switch (statusID & 0xff)
    {
      case 0x80: /* This status/ID is generated by device 1. */
          /*
             Process the interrupt.
          */
          break;


      case 0x90: /* This status/ID is generated by device 2. */
          /*
             Process the interrupt.
          */
          break;


      default:
          break;
    }
}



main()
{
   int16      retval;
   int16      controller;
   uint16     mylevels;


      /* Initialize the NI-VXI software at the start of
        the application. */

   if (InitVXIlibrary() < 0)
    {
         /* Error in InitVXIlibrary */
      printf("InitVXIlibrary failed.  Unable to continue\n");
      exit(0);
   }
   mylevels = (1<< (2-1));  /* VME interrupter interrupts on
                              level 2 */

      /* Install sample VME interrupt handler. Whenever there
        is an interrupt on VME interrupt level 2 and is
        enabled, the function ExampleVMEintHandler is
        executed. */

   retval = SetVXIintHandler(mylevels, ExampleVMEintHandler);


   controller = GetMyLa();      /* Get the logical address
                                  of the controller. */

    /* Handle the interrupt on level 2 as a VME interrupt. */
   Sroute &= ~(1<< (2-1));
      /* Route the status/ID value retrieved from a VME
        interrupt acknowledge cycle to a VME interrupt
        handler. */

   retval = RouteVXIint(controller, Sroute);


   modes &= ~(1<< (2-1));       /* Set to ROAK VME interrupt
                                  for level 2. */

       /* Handle the VME interrupt acknowledge cycle
         as ROAK. */

    retval = VXIintAcknowledgeMode(controller, modes);


   levels |= (1<< (2-1)); /* Enable interrupts on level 2. */
     /* Sensitize local CPU for the interrupts on level 2. */
   retval = EnableVXIint(controller, levels);


    /*
      Generate the interrupt from the VME device by
     performing the device-specific operations and wait
     for the interrupt to occur.

    */


   levels &= ~(1<< (2-1)); /* Disable interrupts on
                             level 2. */

       /* Desensitize the local CPU for the interrupts
         on level 2. */

   retval = DisableVXIint(controller, levels);


      /* Close the NI-VXI software at the end. */
   retval = CloseVXIlibrary();
}

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit