Technical Information Manual: 25 January 2010 Revision N. 3
Technical Information Manual: 25 January 2010 Revision N. 3
CAEN will repair or replace any product within the guarantee period if the Guarantor declares that the product is defective due to workmanship or materials and has not been caused by mishandling, negligence on behalf of the User, accident or any abnormal conditions or operations.
CAEN declines all responsibility for damages or injuries caused by an improper use of the Modules due to negligence on behalf of the User. It is strongly recommended to read thoroughly the CAEN User's Manual before any kind of operation.
CAEN reserves the right to change partially or entirely the contents of this Manual at any time and without giving any notice.
Title: CAENcomm
Revision: 3
TABLE OF CONTENTS
1. CAENCOMM OVERVIEW ...........................................................................................................................4 1.1. 2. SYSTEM REQUIREMENTS ..........................................................................................................................5
FUNCTION CLASSIFICATION....................................................................................................................6 2.1. CAENCOMM DATA TYPES ......................................................................................................................7 2.1.1. CAENComm_ConnectionType.......................................................................................................7 2.1.2. CAENComm_ErrorCode.................................................................................................................7 2.1.3. CAENCOMM_INFO ......................................................................................................................7 2.1.4. IRQ Levels.......................................................................................................................................7
3.
FUNCTION DESCRIPTIONS........................................................................................................................8 3.1. INITIALIZATION/TERMINATION FUNCTIONS ..............................................................................................8 3.1.1. CAENComm_OpenDevice..............................................................................................................8 3.1.2. CAENComm_CloseDevice .............................................................................................................9 3.1.3. Examples .......................................................................................................................................10 3.1.3.1. Example No.1 .......................................................................................................................10 3.1.3.2. Example No.2 .......................................................................................................................11 3.2. DATA TRANSFER FUNCTIONS ..................................................................................................................13 3.2.1. CAENComm_Write32 ..................................................................................................................13 3.2.2. CAENComm_Write16 ..................................................................................................................14 3.2.3. CAENComm_Read32 ...................................................................................................................15 3.2.4. CAENComm_Read16 ...................................................................................................................16 3.2.5. Multi read/write functions .............................................................................................................17 3.2.5.1. CAENComm_MultiRead32 ..................................................................................................17 3.2.5.2. CAENComm_MultiRead16 ..................................................................................................18 3.2.5.3. CAENComm_MultiWrite32..................................................................................................19 3.2.5.4. CAENComm_MultiWrite16..................................................................................................20 3.2.6. CAENComm_BLTRead................................................................................................................21 3.2.7. CAENComm_MBLTRead ............................................................................................................22 3.3. INTERRUPT HANDLING FUNCTIONS ........................................................................................................23 3.3.1. CAENComm_IRQDisable ............................................................................................................23 3.3.2. CAENComm_IRQEnable .............................................................................................................23 3.3.3. CAENComm_IRQWait.................................................................................................................24 3.3.4. CAENComm_IACKCycle ............................................................................................................25 3.3.5. CAENComm_VMEIRQWait ........................................................................................................26 3.3.6. CAENComm_VMEIRQCheck......................................................................................................27 3.3.7. CAENComm_ VMEIACKCycle16...............................................................................................28 3.3.8. CAENComm_ VMEIACKCycle32...............................................................................................29 3.3.9. Details and Examples ....................................................................................................................29 3.4. UTILITY FUNCTIONS ...............................................................................................................................31 3.4.1. CAENComm_Info.........................................................................................................................31 3.4.2. CAENComm_SWRelease .............................................................................................................32 3.4.3. CAENComm_ DecodeError..........................................................................................................32
LIST OF FIGURES
FIG. 1.1: HARDWARE AND SOFTWARE LAYERS.....................................................................................................5 FIG. 3.1: BLOCK DIAGRAM OF EXAMPLE NO.1 ....................................................................................................10 FIG. 3.2: BLOCK DIAGRAM OF EXAMPLE NO.2 ....................................................................................................11
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 3
Title: CAENcomm
Revision: 3
1.
CAENComm overview
CAEN has developed a family of acquisition modules (ADC, TDC, etc ...) with different standards and formats (VME, NIM, Desktop and others). They all provide the possibility to be handled and readout by a host PC via several communication channels. The purpose of the CAENComm library is to implement a common interface to the higher software layers, masking the details of the physical channel and its protocol, thus making the libraries and applications that rely on the CAENComm independent from the physical layer. Moreover, the CAENComm is based in turn on CAENVMElib, a library developed specifically for USB-VME bridge (Mod V1718) and PCI-VME (Mod V2718), which implements the basic functions for accessing the VME bus (besides other specific functions for these bridge). For this reason, it is necessary that the CAENVMELib is already installed on your PC before installing the CAENComm; however, the CAENVMELib is completely transparent to the user. Currently, the CAENComm supports the following channels of communication: 1. PC => USB => CAEN Front-end Modules with USB 2.0 interface: CAEN Waveform digitizers with USB (NIM/Desktop form factors) N957 8k Multi-Channel Analyzer 2. PC => USB => V1718 => VME => all CAEN VME Modules 3. PC => PCI (A2818) => CONET => CAEN Modules with Opt. link: Waveform digitizers (VME, NIM/Desktop form factors) SY2791 TPC Readout System 4. PC => PCI (A2818) => CONET => V2718 => VME => all CAEN VME Modules Conet (Chainable Optical NETwork) indicates the CAEN proprietary protocol for communication on Optical Link. A new type of PCIe communication card (A3818) with four optical links will soon replace or complement the PCI card A2818. It is possible to develop a software for one CAEN VME card (such as a digitizer) with a bus controller different from those proposed by CAEN (such as a VME-SBC); in this case it is necessary to provide a CAENComm equivalent library by exporting only the functions used by the software. interface
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 4
Title: CAENcomm
Revision: 3
1.1.
System Requirements
CAENComm supports the following platforms: Windows 2003/XP/Vista or Linux kernel Rel. 2.4/2.6 with gnu C/C++ compiler LabView 8.2 professional (for LabVIEW VIs)
The hardware and software layers are reported in the following scheme:
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 5
Title: CAENcomm
Revision: 3
2. Function classification
CAENComm functions are divided into 4 groups: Device Initialization/Termination Functions CAENComm_OpenDevice CAENComm_CloseDevice Data Transfer Functions CAENComm_Write16 CAENComm_Read32 CAENComm_Read16 CAENComm_MultiRead32 CAENComm_MultiRead16 CAENComm_MultiWrite16 CAENComm_MultiWrite32 CAENComm_BLTRead CAENComm_MBLTRead Interrupt Handling Functions CAENComm_IRQDisable CAENComm_IRQEnable CAENComm_IRQWait CAENComm_IACKCycle CAENComm_VMEIRQWait Information recovery functions CAENComm_Info CAENComm_SWRelease CAENComm_DecodeError
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 6
Title: CAENcomm
Revision: 3
2.1.
2.1.2. CAENComm_ErrorCode
Error code CAENComm_Success CAENComm_VMEBusError CAENComm_CommError CAENComm_GenericError CAENComm_InvalidParam CAENComm_InvalidLinkType CAENComm_InvalidHandler CAENComm_CommTimeout CAENComm_DeviceNotFound CAENComm_MaxDevicesError CAENComm_DeviceAlreadyOpen CAENComm_NotSupported CAENComm_UnusedBridge CAENComm_Terminated Value 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 Meaning Operation completed successfully VME bus error during the cycle Communication error Unspecified error Invalid parameter Invalid Link Type Invalid device handler Communication Timeout Unable to Open the requested Device Maximum number of devices exceeded The device is already opened Not supported function There aren't boards controlled by that Bridge Communication terminated by the Device
2.1.3. CAENCOMM_INFO
Code CAENComm_PCI_Board_SN CAENComm_PCI_Board_FwRel CAENComm_VME_Bridge_SN CAENComm_VME_Bridge_FwRel1 CAENComm_VME_Bridge_FwRel2 Value 0 1 2 3 4 Meaning s/n of the PCI/PCIe board Firmware Release of the PCI/PCIe board s/n of the VME bridge Firmware Release for the VME bridge Firmware Release for the optical chipset inside the VME bridge (V2718 only)
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 7
Title: CAENcomm
Revision: 3
3. Function descriptions
3.1. Initialization/termination functions
These functions allow to open and close the connection with a remote board. To open one board is necessary to describe the 'logical' path from the PC to the device to access (one of the path indicated in the introduction). This path is specified by the input parameters of the OpenDevice function. Once the device is opened, the function returns a handle that becomes the unique identifier of that device; any access operation to the device (except for VME cards IRQ management described in ) will take place according to its handle, thus making transparent the physical channel.
3.1.1. CAENComm_OpenDevice
Description This function allows to open the device Input Parameters Name LinkType Type CAENComm_ConnectionType Description LinkType: The link used by the device 0: CAENComm_USB 1: CAENComm_PCI_OpticalLink 2: CAENComm_PCIE_OpticalLink 3: CAENComm_PCIE LinkNum: when using OpticalLink, it is the optical link number to be used when using USB, it is the USB device number to be used ConetNode: for OpticalLink identify which device in the daisy-chain is addressed for USB must be 0. The VME base address of the board in case you want to access a VME device, 0 otherwise Description The handler to use for access to the device
LinkNum
Int
ConetNode
int
VMEBaseAddress
uint32_t
Type int
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 8
Title: CAENcomm
Revision: 3
C++ Representation CAENComm_ErrorCode CAENComm_OpenDevice( CAENComm_ConnectionType int int uint32_t VMEBaseAddress, int LinkType, LinkNum, ConetNode, *handle);
3.1.2. CAENComm_CloseDevice
Description
handle
Return Type CAENComm_ErrorCode
int
device handler
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 9
Title: CAENcomm
Revision: 3
Fig. 3.1: Block diagram of example no.1 The host PC houses two CAEN A2818; the VME crate houses the following boards: a) Bridge CAEN V2718 physically connected via optical links to the PCI card A2818 N. 0 b) Two Digitizers CAEN (model V1724 with VME base address 0x32100000 and model V1740 with VME base address 0x40000000) c) Two Digitizers CAEN (model V1724 and V1731 model) connected in a daisy chain between them and to the PCI card A2818 N. 1 The open for the 4 cards to access are: Open the V1724 (VME BASE ADDRESS 0x32100000) accessed via VMEbus through the V2718: CAENComm_OpenDevice( Physical link CAENComm_PCI_OpticalLink, PCI board n. 0, Device in chain 0, VME Base address 0x32100000, &handleV1724_0); Open the V1740 (VME BASE ADDRESS 0x40000000) accessed via VMEbus through the V2718: CAENComm_OpenDevice( Physical link CAENComm_PCI_OpticalLink,
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 10
Title: CAENcomm
Revision: 3
0, 0, 0x40000000, &handleV1740);
Open the V1724 (first in daisy chain) directly accessed via Optical Link CAENComm_OpenDevice( Physical link CAENComm_PCI_OpticalLink, PCI board n. 1, Device in chain 0, not used 0, &handleV1724_1); Open the V1731 (second in daisy chain) directly accessed via Optical Link CAENComm_OpenDevice( Physical link CAENComm_PCI_OpticalLink, PCI board n. 1, Device in chain 1, not used 0, &handleV1731);
3.1.3.2.
Example No.2
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 11
Title: CAENcomm
Revision: 3
Host PC houses two USB ports and a A3818 card; it is connected to three crates, respectively VME, NIM and Sy2791, housing the following boards: a) VME Crate - Bridge CAEN V1718 physically connected to the PC via USB cable - Digitizer model V1724 with VME base address 0x12340000 b) NIM Crate - Multi Channel Analyzer model N957 physically connected to the PC via USB cable c) Crate SY2791 - Model A2792 Acquisition module physically connected via optical links to the PCI Express A3818 The open for the 3 cards to access are: Open the V1724 accessed from VMEbus through V1718 CAENComm_OpenDevice( Physical link CAENComm_USB, USB link n. 0, not used 0, VME Baseaddress 0x12340000, &handleV1724); Open the N957 connected via USB cable CAENComm_OpenDevice( Physical link CAENComm_USB, USB link n. 1, not used 0, not used 0, &handleN957); Open the SY2792 connected via Optical Link CAENComm_OpenDevice( Physical link CAENComm_PCIE_OpticalLink, PCIE link n. 0, Device in chain 0, not used 0, &handleSY2792);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 12
Title: CAENcomm
Revision: 3
3.2.
C++ Representation: CAENComm_ErrorCode CAENComm_Write32( int handle, uint32_t Address, uint32_t Data);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 13
Title: CAENcomm
Revision: 3
3.2.2. CAENComm_Write16
Description
C++ Representation: CAENComm_ErrorCode CAENComm_Write16( int handle, uint32_t Address, uint16_t Data);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 14
Title: CAENcomm
Revision: 3
3.2.3. CAENComm_Read32
Description This function allows to read 32 bit register of the device Input Parameters Name handle Address Output Parameters Name Data Return Type CAENComm_ErrorCode Type int uint32_t Type uint32_t Description device handler register address offset Description The data read from the device
C++ Representation: CAENComm_ErrorCode CAENComm_Read32( int handle, uint32_t Address, uint32_t *Data);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 15
Title: CAENcomm
Revision: 3
3.2.4. CAENComm_Read16
Description This function allows to read 16 bit register of the device Input Parameters Name handle Address Output Parameters Name Data Return Type CAENComm_ErrorCode Type int uint32_t Type Uint16_t Description device handler register address offset Description the data read from the device
C++ Representation: CAENComm_ErrorCode CAENComm_Read16( int handle, uint32_t Address, uint16_t *Data);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 16
Title: CAENcomm
Revision: 3
3.2.5.1.
CAENComm_MultiRead32
Description The function performs a sequence of single 32bit Read operation Input Parameters Name handle Address nCycle Output Parameters Name data ErrorCode Return Type CAENComm_ErrorCode Type int uint32_t [ ] int Type uint32_t [ ] CAENComm_ErrorCode Description device handler register address offsets the number of read to perform Description the data read from the device the error codes relative to each cycle
C++ Representation: CAENComm_ErrorCode CAENComm_MultiRead32( int uint32_t int uint32_t CAENComm_ErrorCode handle, *Address, nCycles, *data, *ErrorCode);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 17
Title: CAENcomm
Revision: 3
3.2.5.2.
CAENComm_MultiRead16
Description The function performs a sequence of single 16 bit Read operation Input Parameters Name handle Address nCycles Output Parameters Name data ErrorCode Return Type CAENComm_ErrorCode Type int uint32_t [ ] int Type uint16_t [ ] CAENComm_ErrorCode Description device handler register address offsets the number of read to perform Description the data read from the device the error codes relative to each cycle
CAENComm_ErrorCode
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 18
Title: CAENcomm
Revision: 3
3.2.5.3.
CAENComm_MultiWrite32
Description The function performs a sequence of single 32 bit Write operation Input Parameters Name handle Address nCycles data Output Parameters Name ErrorCode Return Type CAENComm_ErrorCode Type int uint32_t [ ] int uint32_t [ ] Type CAENComm_ErrorCode Description device handler register address offsets the number of read to perform the data to write to the device Description The error codes relative to each cycle
C++ Representation: CAENComm_ErrorCode CAENComm_MultiWrite32( int uint32_t int uint32_t CAENComm_ErrorCode handle, *Address, nCycles, *data, *ErrorCode);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 19
Title: CAENcomm
Revision: 3
3.2.5.4.
CAENComm_MultiWrite16
Description The function performs a sequence of single 16 bit Write operation Input Parameters Name handle Address nCycles data Output Parameters Name ErrorCode Return Type CAENComm_ErrorCode Type int uint32_t [ ] int Uint16_t [ ] Type CAENComm_ErrorCode Description device handler register address offsets the number of read to perform the data to write to the device Description The error codes relative to each cycle
C++ Representation: CAENComm_ErrorCode CAENComm_MultiWrite16( int uint32_t int uint16_t CAENComm_ErrorCode handle, *Address, nCycles, *data, *ErrorCode);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 20
Title: CAENcomm
Revision: 3
3.2.6. CAENComm_BLTRead
Description This function allows to read a block of data from the device using a BLT (32 bit) cycle Input Parameters Name handle Address BltSize Output Parameters Name buff nw Return Type CAENComm_ErrorCode Type int uint32_t int Type uint32_t int Description device handler data space starting address size of the Block Read Cycle (in bytes) Description pointer to the read data buffer number of longwords (32 bit) actually read from the device
C++ Representation: CAENComm_ErrorCode CAENComm_BLTRead( int handle, uint32_t Address, uint32_t *Buff, int BltSize, int *nw);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 21
Title: CAENcomm
Revision: 3
3.2.7. CAENComm_MBLTRead
Description This function allows to read a block of data from the device using an MBLT (64 bit) cycle Input Parameters Name handle Address BltSize Output Parameters Name buff nw Return Type CAENComm_ErrorCode Type int uint32_t int Type uint32_t int Description device handler data space starting address size of the Block Read Cycle (in bytes) Description pointer to the read data buffer number of longwords (32 bit) actually read from the device
C++ Representation: CAENComm_ErrorCode CAENComm_MBLTRead ( int handle, uint32_t Address, uint32_t *Buff, int BltSize, int *nw);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 22
Title: CAENcomm
Revision: 3
3.3.
3.3.2. CAENComm_IRQEnable
Description This function enables the IRQ lines Input Parameters Name handle Return Type CAENComm_ErrorCode Type int Description device handler
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 23
Title: CAENcomm
Revision: 3
3.3.3. CAENComm_IRQWait
Description The function waits the IRQ lines specified by Mask until one of them raise or timeout expires This function can be used ONLY on board NOT controlled by CAEN VME Bridges Input Parameters Name handle Timeout Return Type CAENComm_ErrorCode Type int uint32_t Description device handler timeout in milliseconds
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 24
Title: CAENcomm
Revision: 3
3.3.4. CAENComm_IACKCycle
Description The function performs an interrupt acknowledge cycle Input Parameters Name handle Level Output Parameters Name BoardID Return Type CAENComm_ErrorCode Type int
IRQLevels
Description device handler the IRQ level to acknowledge Description the Id of the Board that raised the interrupt
Type int
C++ Representation: CAENComm_ErrorCode CAENComm_IACKCycle( int handle, IRQLevels Level, int *BoardID);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 25
Title: CAENcomm
Revision: 3
3.3.5. CAENComm_VMEIRQWait
Description The function waits the IRQ until one of them raises or timeout expires Input Parameters Name LinkNum Type CAENComm_Connectio nType Description when using OpticalLink , it is the optical link number to be used when using USB, it is the USB device number to be used LinkType: The link used by the device 0: CAENComm_USB 1: CAENComm_PCI_OpticalLink 2: CAENComm_PCIE_OpticalLink 3: CAENComm_PCIE the CAEN VME Bridge number in the link timeout in milliseconds Description the CAEN Bridge handle to use in VMEIRQCheck and VMEIACKCycle
LinkType
int
C++ Representation: CAENComm_ErrorCode CAENComm_VMEIRQWait( CAENComm_ConnectionType int int uint32_t int LinkType, LinkNum, ConetNode, Timeout, *VMEHandle);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 26
Title: CAENcomm
Revision: 3
3.3.6. CAENComm_VMEIRQCheck
Description The function returns a bit mask indicating the active IRQ lines Input Parameters Name handle Output Parameters Name Mask Return Type CAENComm_ErrorCode Type int Type uint8_t Description device handler Description a bit-mask indicating the IRQ lines
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 27
Title: CAENcomm
Revision: 3
Description device handler The IRQ level to acknowledge (see IRQLevels enum) Description the Id of the Board that read the interrupt
Type int
C++ Representation: CAENComm_ErrorCode CAENComm_VMEIACKCycle16( int VMEhandle, IRQLevels Level, int *BoardID);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 28
Title: CAENcomm
Revision: 3
Description device handler The IRQ level to acknowledge (see IRQLevels enum) Description the Id of the Board that read the interrupt
Type int
C++ Representation: CAENComm_ErrorCode CAENComm_VMEIACKCycle32( int VMEhandle, IRQLevels Level, int *BoardID);
Title: CAENcomm
Revision: 3
The function waits either until the bridge that manages the VME boards (specified by the function parameters) raises an IRQ or the timeout to expire. As this function returns an VMEHandle, in order to acknowledge which board raised the IRQ, it is necessary to use the function CAENComm_VMEIRQCheck
Examples: Examples: ( For a setup like picture shown in 3.1.3.1 ) 1) In order to handle the IRQ of boards V1740 (BA 0x40000000) and V1724 (BA 0x32100000) IRQ manage for boards in 3.1.3.1 CAENComm_VMEIRQWait( Physical link CAENComm_PCI_OpticalLink, PCI board n. 0, Device in chain 0, IRQmask 0xff Timeout 5000, Handle of bridge that raises the IRQ &VMEHandle); then CAENComm_VMEIRQCheck and / or CAENComm_VMEIACKCycle32 can be used to acknowledge the activated IRQ Level 2) in order to handle the IRQ of boards connected to the A2818#1; CAENComm_IRQWait( handleV1724_1, Timeout 5000); and CAENComm_IRQWait( handleV1731, Timeout 5000);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 30
Title: CAENcomm
Revision: 3
3.4.
Utility Functions
3.4.1. CAENComm_Info
Description The function returns information about serial number or firmware release of the device Input Parameters Name handle info Output Parameters Name data Return Type CAENComm_ErrorCode Type int CAENCOMM_INFO Type char Description device handler The interested info (see 2.1.3) Description an array (user defined to 30 byte) with the requested info
C++ Representation: CAENComm_ErrorCode CAENComm_Info( int CAENCOMM_INFO char handle, info, *data);
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 31
Title: CAENcomm
Revision: 3
3.4.2. CAENComm_SWRelease
Description The function returns the Software Release of the library Input Parameters Name SwRel: Return Type CAENComm_ErrorCode Type char Description the Software Release of the library
Filename: CAENcomm_rev3.doc
Number of pages: 32
Page: 32