[SLAC Controls Software Group [SLAC Controls Department] [SLAC Home Page]

Go to bottom of page



9.1 DATA STRUCTURES . . . . . . . . . . . . . . . . . 9-1

9.1.1 CTLW -- CAMAC ConTroL Word . . . . . . . . . . . 9-2

9.1.1.1 Scan Modes . . . . . . . . . . . . . . . . . . 9-3

9.1.1.2 Pack Modes . . . . . . . . . . . . . . . . . . 9-4

9.1.1.3 RE_PACK . . . . . . . . . . . . . . . . . . . 9-5

9.1.2 Status/Data Buffer Format . . . . . . . . . . . 9-5

9.1.3 EMASK - Error Reporting Mask . . . . . . . . . . 9-6

9.1.4 Package Format . . . . . . . . . . . . . . . . . 9-8

9.1.4.1 Data Ptr . . . . . . . . . . . . . . . . . . . 9-8

9.1.4.2 WCMAX . . . . . . . . . . . . . . . . . . . . 9-8

9.1.4.3 CIC . . . . . . . . . . . . . . . . . . . . . 9-8

9.2 SOFTWARE . . . . . . . . . . . . . . . . . . . . . 9-9

9.2.1 CAMIO . . . . . . . . . . . . . . . . . . . . 9-10

9.2.2 CAMALO . . . . . . . . . . . . . . . . . . . . 9-11

9.2.3 CAMADD . . . . . . . . . . . . . . . . . . . . 9-12

9.2.4 CAMGO . . . . . . . . . . . . . . . . . . . . 9-13

9.2.5 CAMGO_R . . . . . . . . . . . . . . . . . . . 9-13

9.2.6 CAMMOD . . . . . . . . . . . . . . . . . . . . 9-14

9.2.7 CAMFAG . . . . . . . . . . . . . . . . . . . . 9-14

9.2.8 CAMDEL . . . . . . . . . . . . . . . . . . . . 9-15

9.2.9 CAMALO_RESET . . . . . . . . . . . . . . . . . 9-15

9.2.10 CAMEXIT . . . . . . . . . . . . . . . . . . . 9-16 CHAPTER 9 8086 CAMAC SYSTEM CAMAC operations on the 8086 Single Board Computers (SBCs) are carried out through the MultiBus Camac Driver (MBCD). The MBCD is a multibus master device containing two registers: the Start Input/Output (SIO) register [multibus port 120(16)] and the Test DeVice (TDV) register [multibus port 122(16)]. TIME RESTRICTION: A CAMAC operation, once begun in the MBCD, cannot be aborted. The master beam trigger interrupt routine needs access to the CAMAC systems at 2.8 millisecond intervals. We consequently impose the restriction (rigorously enforced by the hardware) that no CAMAC operation (complete package) may take longer than 1 millisecond to complete. (At 10-15 microseconds/word this allows a maximum of 70-100 word transfers per package). The execution time of a CAMAC package may be approximately calculated by the following formula: Time = 12 * ( #_of_packets + #_words_data ) microseconds. The above time restriction may be avoided for long CAMAC transfers by the use of the "RE_PACK" bit in the CTLW (see below).

9.1 DATA STRUCTURES


8086 CAMAC SYSTEM Page 9-2

9.1.1 CTLW -- CAMAC ConTroL Word The CTLW is a I*4 word describing the CAMAC operation to be executed. The 32 bits have meanings as described below: The following bits are also available from the following include files: INCLUDE '(CTLWBITS)' (vax/vms fortran 77) $ INCLUDE (SLCRMX:CTLWBITS.INC) (intel fortran-86) $ INCLUDE (SLCRMX:CAMAC.PNC) (intel pl/m-86) CTLW = MXXQ|QPII|SSSF|FFFF|CCCC|NNNN|NxPR|AAAA PMMM|M2NL|CNA1|8421|8421|1842|1 8P|8421 C121|24 Q| 6| | |6 | K| Bits 0-3 = AAAA = Module subaddress. 4 = RE_PACK = Re_pack data into smaller blocks. 5 = P8 = 8-bit pack mode. (See Pack Modes below). 6 = x = Not used (yet). 7-11 = NNNNN= Station address 12-15 = CCCC = Crate address 16-20 = FFFFF= CAMAC function code. 21-23 = SSS = Enables scan mode counters. (See Scan Modes below.) 21 = SA = Enable subaddress counter. 22 = SN = Enable station address counter. 23 = SC = Enable crate counter. 24-25 = II = Scan Increment mode (see Scan Modes below). 24 = ILQ = Increment enabled counters only if Q=0. 25 = IN = Reset least significant enabled counter and increment next most significant enabled counter if X=0. 26 = P24 = 24-bit pack mode. (See Pack Modes below). 27-30 = XXQQ = Transfer/terminate mode (See Scan modes below.) 27 = QM2 = Terminate packet if Q=0. 28 = QM1 = Transfer data iff Q=1. 29 = XM2 = Terminate packet if X=0. 30 = XM1 = Transfer data iff X=1.


8086 CAMAC SYSTEM Page 9-3 31 = MPC = 0 if last packet of package; otherwise More Packets Coming.

9.1.1.1 Scan Modes - Scan modes are controlled by the fields SSS, XXQQ, and II. SA, SN, and SC enable the subaddress, station, and crate counters respectively. The subaddress counter is the least significant counter, and the crate counter is most significant. Setting XM1 or QM1 allows actual data transfers only if X=1 (if XM1 set) or Q=1 (if QM1 set). Packet operations are terminated by maximum word count transferred (n.b. this is always zero for non-data transfer operations (F8=1)), or by X=0 if XM2 is set, or by Q=0 if QM2 is set, or by the overflow of the most significant enabled counter. (A overflows beyond 15, N beyond 23, and C beyond 23.) Incrementing of enabled counters is controlled by II as follows: IN ILQ -- --- 0 0 Increment the least significant counter each CAMAC cycle. On overflow, reset the least significant counter and increment the next-most-significant counter. 0 1 Increment the least significant counter if and only if Q=0. On overflow, reset the least significant counter and increment the next-most-significant counter. 1 0 Increment the least significant counter each CAMAC cycle. On overflow, reset the least significant counter but do NOT increment the next-most-significant counter. If and only if X=0, reset the least significant counter and increment the next-most-significant counter. 1 1 Increment the least significant counter if and only if Q=0. On overflow OR X=0, reset the least significant counter and increment the next-most significant counter.


8086 CAMAC SYSTEM Page 9-4

9.1.1.2 Pack Modes - CAMAC Pack Modes bits control the "packing" of the CAMAC data to/from the users data buffer. The CAMAC data highway is intrinsically a 24-bit system, but the SLC CAMAC system is based on a 16-bit processor system. There are 4 data packing modes used with the SLC MBCD CAMAC system. o Pack-16 - This is the default. Data is read to/from CAMAC in 16-bit words, using only the lower 16-bits of the CAMAC highway (W1-W16/R1-R16). A byte count of 6 will execute 3 CAMAC reads and write the data in 3 words of the users data buffer. o Pack-24 (Also known as Pack-32) - Data is read to/from CAMAC using the full 24-bit CAMAC highway, and stored in 2 16-bit words in the users data buffer. A byte count of 12 will execute 3 CAMAC reads, and write the data in 6 words of the users data buffer. The CAMAC data is sign extended to 32-bits. o Pack-8 - Data is read to/from CAMAC using the Pack-16 mode (above) into an internal buffer by the software and copied to/from the users data buffer as 8-bit words. A byte count of 3 will execute 3 CAMAC reads, and write the data in 3 bytes (1 1/2 words) of the users buffer. When Pack-8 is requested, the "remaining word count" in the status buffer is the number of BYTES of the user's data remaining to be transfered. o Long-Word - When a module (such as the SAM) reports data in the "long-word" format the module is usually read with the "Pack-16" data transfer mode, and a byte count divisible by 4. A byte count of 12 will execute 6 CAMAC reads, and write the data in 6 words (or 3 long-words or 3 real-numbers) of the user's buffer. This is described for information only, since the CAMAC hardware and software is unaware of such transfers.


8086 CAMAC SYSTEM Page 9-5

9.1.1.3 RE_PACK - Asserting this bit will force the CAMAC driver in the micro to re-build the requested single packet CAMAC transaction into 64 word transfers. This feature, combined with the natural limitations of the SLC Message Service place the maximum camac write at 487 words (874 bytes), and the maximum read limited by the availability of dynamic memory in the micro (20 K-byte ??). This feature is provided to allow the reading of devices such as transient waveform digitizers (1024 byte buffer) and is NOT intended for use by the standard facility software in the micros.

9.1.2 Status/Data Buffer Format Each CAMAC packet (as opposed to CAMAC package) has an associated status/data buffer whose format is as follows: word 0 = STAT0 1 = STAT1 2-n = DATA where |CCCC|NNNN|NDCB|EEXQ|SL--|word|-cou|nt--| STAT = |8421|1842|1NTA|OM |HA | | | | | |6 | EOR|SS |EM | | | | and STAT = STAT1//STAT0 STAT0 = Summary error and remaining word count: bits 0-13 = Remaining word count (NOT BYTECOUNT!!!) after packet completion. Note that iff packet was terminated by QM2 or XM2, or End Of Scan, the remaining word count is 1 less than anticipated for ANY CAMAC WRITE operation. Also if PACK8 is being used, one word is required for each byte transferred so these bits give (in effect) remaining bytecount.


8086 CAMAC SYSTEM Page 9-6 14 = LAM, indicating that some enabled module on the branch is asserting LAM. bit 15 = Summary Hardware Error: present when any of the condi- tions below exist in the MBCD's internal TDV register: PTO -- Package TimeOut. Bytecount of packet was probably too large. This is the most frequent cause of SHE. BTO -- multi-Bus TimeOut. Hard (impossible??) for this condition to exist and still have the STATus written into memory. BOO -- Buffer Offset Overflow. Can occur if the offset of the Stat_Data address overflows. Possible only from the micro with a LARGE (>64 K-byte) Stat_Data array (A no-no). STAT1 = Last crate and module + termination status: bit 0 = Q on last CAMAC cycle. (Meaningful only if CAMAC oper- ation actually occurred (e.g. no crate timeout)) 1 = X on last CAMAC cycle. (Meaningful only if CAMAC oper- ation actually occurred (e.g. no crate timeout)) 2 = EMS = End-Mode-Signal indicating that the packet was terminated by specified (non-zero) XM2, QM2 conditions. 3 = EOS = End-Of-Scan indicating that the packet was term- inated by the overflow of the most significant counter. 4 = BAR = (BARrow) indicating that the packet was termina- ted by RWC=0 (remaining word count). 5 = CTO = Crate TimeOut indicating that the packet was terminated by a CAMAC timeout (n.b. this bit is NOT included in the summary hardware error bit). 6 = DNE = DoNE is set if the CAMAC package (as opposed to packet) is complete. 7-11 = NNNNN = station address of last CAMAC cycle. 12-15 = CCCC = Crate address of last CAMAC cycle.

9.1.3 EMASK - Error Reporting Mask The "EMASK" used by CAMIO, and CAMADD regulates both the signaling of errors, and the returned status from the CAMIO and CAMGO calls. returned signaled


8086 CAMAC SYSTEM Page 9-7 --------- --------- EMASK = |SSCB|EEXQ|SSCB|EEXQ| |HTTA|OM |HTTA|OM | |EOOR|SS |EOOR|SS | The least significant byte selects errors for which warning messages are issued; the most significant byte selects conditions for which errors are indicated in the return code. Bit structure: bits 0 = Q = No Q response 1 = X = No X response 2 = EMS = Did not terminate on End-of-Mode-Signal. (XM2/QM2 conditions) 3 = EOS = Did not terminate on End-of-Scan. (Most significant counter overflow) 4 = BAR = Did not terminate on word count 5 = CTO = Crate timeout (typically crate off-line) 6 = STO = Software timeout (MBCD failed to complete within 50 (??) milli-seconds. Typically bad MBCD.) 7 = SHE = Summary MBCD hardware error Note that bits 2 through 4 are usually mutually exclusive, and should be set (or not) according to the intent of the operation. In the case of multiple errors, only the first mask-selected error is reported, and errors are searched in the order of bit 6, 7, 5, 4, 3, 2, 1, 0. Successful operations return with code CAM_OKOK. Software errors in the construction of the packet rather than its execution (e.g. odd byte count) are not maskable. They always result in an error message, and always return an error condition.
8086 CAMAC SYSTEM Page 9-8

9.1.4 Package Format A CAMAC package consists of an 8 word control block followed by an arbitrary number of 6-word CAMAC packets in the following format: Word # Item +-------+----------+ | 0 | | Low-order camac control word +-------+ CTLW | | 1 | | High-order camac control word +-------+----------+ | 2 | | Stat/data buffer address offset +-------+ Data Ptr | | 3 | | Stat/data buffer address segment +-------+----------+ | 4 | WC_MAX | Maximum word count +-------+----------+ | 5 | CIC | Completion interrupt code +-------+----------+

9.1.4.1 Data Ptr - Data_Ptr is the offset and segment portions of the status/data buffer to be used for the packet. (See Status/Data Buffer Format above.)

9.1.4.2 WCMAX - WCMAX (14 bits only) is the maximum word (not byte) count to be transferred for this packet. NOTE: For non-data CAMAC commands (F8=1) WCMAX must be zero if the CAMAC packet is expected to terminate after a single CAMAC operation (i.e. if you want the operation to terminate on "word count" rather than scan mode terminators).

9.1.4.3 CIC -


8086 CAMAC SYSTEM Page 9-9 CIC -- not used. ( Set to 0 ).

9.2 SOFTWARE The principal software routines available to the user are: o CAMIO -- for single packet CAMAC transfers with all the dirty work done for the user already. o CAMALO -- Allocates a control block for a CAMAC "package". o CAMADD -- Adds a "packet" to the allocated CAMAC "package". o CAMGO -- Executes a prepared CAMAC "package". o CAMGO_R-- Executes a prepared CAMAC "package", and sends the SLC micro a message to continue executing the package "forever". o CAMMOD -- Modifies the CTLW's of (ie: address) of an existing package, and executes the package (via CAMGO). o CAMFAG -- Modifies the F-code and sub-address of a single "packet" camac "package" and executes the packet (via CAMGO). o CAMDEL -- Deletes the control block of an allocated package. o CAMALO_RESET -- Re-initializes an allocated "package". o CAMEXIT -- Sends a message to the indicated micro to stop executing this users repeat function. CAMIO is designed to be partially compatible with the VAX version of CAMIO. However, because of the absence of optional arguments in 8086 FORTRAN, its use is restricted to single-packet CAMAC operations. For multi-packet packages, the remaining routines are used. CAMALO is used to initialize construction of a CAMAC package; CAMADD adds a packet to the package; and CAMGO executes the package. CAMDEL may be used to delete packages which will not be re-executed.


8086 CAMAC SYSTEM Page 9-10 These routines may be called either from the micro (8086 CAMAC) or from the VAX (Virtual CAMAC), in which case the CAMAC commands and data are routed to and from the micros using the network facilities. All CAMAC user-callable CAMAC routines are I*4 functions which return standard VMS return codes (see Chapter on Error Messages). For most applications, these codes should simply be logically tested for Success or Failure (ie: IF ( ISS ) THEN). Note particularly that since virtual CAMAC uses a variety of system services and the SLC Message Service, failures in these services will result in a returned error code from the applicable facility. CAMAC facility return codes may be found in the include files CAMDEF.

9.2.1 CAMIO CAMIO performs a single-packet CAMAC operation: ISS = CAMIO( BRCH, CTLW, DATA, BCNT, STATUS, EMASK) ---- ---- ------ ----- Integer*4 CAMIO returned status Integer*4 BRCH micro name, required but not used in micro Integer*4 CTLW control word (Array) DATA status and data array (Optional on VAX non-data) Integer*2 BCNT byte count (Optional on VAX non-data) Integer*4 STATUS returned MBCD status (Optional on VAX) Integer*2 EMASK error mask (Optional on VAX) This is the general purpose "camac" routine. Routines in both the Vax and the Micro do essentially the same functions. Specifically: o Allocates a CAMAC package with a call to CAMALO. o Copies DATA into an internal buffer, if camac write. o Prepares MBCD packet with a call to CAMADD. o Executes the packet with a CAMGO call. o Copies STATUS from an internal buffer.


8086 CAMAC SYSTEM Page 9-11 o Copies DATA from an internal buffer, if camac read. BRCH = (input) CAMAC branch. In 8086 CAMAC this argument is required for consistency but ignored, since a micro-cluster has only one branch. From the VAX, BRCH should be the micro-cluster name (e.g. LI01). CTLW = (input) CAMAC control word as given in the description above. DATA = (input or output) data buffer to be read into or written from. For compatibility with other branch drivers, this buffer is NOT in the format described above. In particular, it contains the data only; the status information is returned separately. DATA is optional in Virtual CAMAC for non-data transfer operations. BCNT = (input) maximum BYTE (not word) count to be transferred. For non-data commands, the byte count **** MUST **** be zero. For Virtual CAMAC, BCNT is optional for non-data-transfer operations (defaults to 0). STATUS = (output) status buffer as described in above. Note that the format and length of this buffer are different from those for other branch drivers. For Virtual CAMAC, STATUS is optional. EMASK= (input) 2 byte (or I*2) error mask as given in the description above.

9.2.2 CAMALO CAMALO allocates and initializes a block for NOPS camac packets. ISS = CAMALO( BRCH, NOPS, PTR) Integer*4 CAMALO returned status Integer*4 BRCH micro name, required but not used in micro Integer*2 NOPS maximum number of operations allowed Addr.Token PTR pointer to control block I*4 for VAX, I*2 for 8086. CAMALO allocates dynamic memory for a CAMAC package. For a given CAMAC package, CAMALO should be called only once. It must, of course, be called after a previous package has been deleted using CAMDEL. BRCH = (input) CAMAC branch. In 8086 CAMAC this argument is required for consistency but ignored, since a micro-cluster has only one branch. From the VAX, BRCH should be the micro-cluster name (e.g. LI01). NOPS = (input) maximum number of CAMAC operations (packets) to be included in the package. RESTRICTION: NOPS<64.


8086 CAMAC SYSTEM Page 9-12 PTR = (output) pointer containing the segment address of a control block to be used for future references to the package. For VAX/VMS the address is stored as a Integer*4, and in the Intel 8086, the address token is a Integer*2.

9.2.3 CAMADD CAMADD adds a single packet to a Camac package. ISS = CAMADD( CTLW, STAT_DATA, BCNT, EMASK, PTR) Integer*4 CAMADD returned status Integer*4 CTLW control word (Array) STAT_DATA status and data array Integer*2 BCNT byte count Integer*2 EMASK error mask Addr.Token PTR pointer to control block CAMADD adds a single packet to a CAMAC package. It should be called once for each packet to be included in the package. This should be done only at initialization time, and NOT each time the package is executed. CTLW = (input) CAMAC control word for the packet, as described above. STAT_DATA = (input) Status and Data buffer for this packet as described above. ***************************************************************** * This buffer must be present even for non-data commands, * * and must be dimensioned (in words) 2 + (max data words). * * If the same buffer is used for different packets within * * a single package, then, for write or non-data operations, * * the status of the first packet will be overwritten by * * that of the second. For read operations, both status and * * data will be overwritten. * ***************************************************************** BCNT = (input) Maximum byte (NOT word) count to be transferred for this packet (does NOT include status portion of buffer). For non-data-transfer, non-scan-mode commands, the byte count **** MUST **** be ZERO. EMASK= (input) 2 byte (or I*2) error mask as given in the description above. PTR = (input) Control block pointer for this package obtained from CAMALO.


8086 CAMAC SYSTEM Page 9-13

9.2.4 CAMGO Executes an already prepared Camac package, and checks the results for errors against the EMASK error mask. ISS = CAMGO( PTR) Integer*4 CAMGO returned status Addr.Token PTR pointer to control block CAMGO executes a CAMAC package prepared using CAMALO and CAMADD. Having once been prepared, CAMGO can be executed any number of times. Data and status for the package are returned in (or taken from) the data buffers specified in the calls to CAMADD.

9.2.5 CAMGO_R Executes an already prepared Camac package, and checks the results for errors against the EMASK error mask. The micro is sent a message to continuing executing the package "forever" (see notes below). ISS = CAMGO_R( PTR) Integer*4 CAMGO returned status Addr.Token PTR pointer to control block CAMGO_R executes a CAMAC package as described in CAMGO above, and includes in the message to the SLC micro a request to repeat the package at a high rate. This feature is designed to allow service technicians to debug modules at workbenches with greater ease. It IS NOT expected to be used in normal production SLC control software. Use of CAMGO_R is subject to the following restrictions: o RE_PACK and PACK8 options are not allowed. Both of these options require re-processing of the data in the micro. o Error checking is ONLY done on the first execution of the package.


8086 CAMAC SYSTEM Page 9-14 o Repeat rate is limited by the availability of the micro, but should be about 100 Hertz. o Repeat function is canceled when ANY other CAMAC or GPIB transaction occures from a VAX process with the same interrupt ID. o Repeat function is canceled when the repeat count exceeds the maximum.

9.2.6 CAMMOD CAMMOD is an interesting little routine of a pleasant color. It modifies the CTLW's of all packets of an existing package, and executes it (via CAMGO). ISS = CAMMOD( CTLW, MASK, PTR) Integer*4 CAMMOD returned status Integer*4 CTLW control word Integer*4 MASK mask of CTLW bits to modify Addr.Token PTR pointer to control block All CAMAC packets in the package are modified, and the package is executed (via a CAMGO). The following operations are performed: o All CTLW's have the bits present in the MASK cleared. o All CTLW's have the bits which are in both the MASK and the new CTLW set. o The package is executed. o The return status from CAMGO is returned as CAMMOD. Note that the package is permanently modified so that all subsequent calls to CAMGO will execute the new CTLW.

9.2.7 CAMFAG CAMFAG changes the function code and subaddress of a single-packet


8086 CAMAC SYSTEM Page 9-15 CAMAC package, and then executes it (via CAMGO). Note: This is an older and less flexible version of CAMMOD which may be more convenient in certain applications. ISS = CAMFAG(F,A,PTR) Integer*4 CAMFAG returned status Integer*4 F Function Code Integer*4 A Sub-Address Addr.Token PTR pointer to control block The F and A are converted to the appropriate CTLW bits, and replace the previous F and A information in the CTLW of the first packet in the CAMAC package. Note that the package is permanently modified so that all subsequent calls to CAMGO will execute the new CTLW.

9.2.8 CAMDEL CAMDEL deletes the virtual memory allocated for a CAMAC package using CAMALO and sets PTR to zero. ISS = CAMDEL( PTR ) Addr.Token PTR pointer to control block

9.2.9 CAMALO_RESET Resets the package packets to the virgin state, allowing a new set of camac packets to be added. From the VAX only, the package brch may optionally be reset to allow the package packets to be sent to a new micro. ISS = CAMALO_RESET( PTR ) micro version ISS = CAMALO_RESET( PTR, BRCH ) VAX version ---- Addr.Token PTR pointer to control block Integer*4 BRCH micro name, required but not used in micro


8086 CAMAC SYSTEM Page 9-16 CAMALO_RESET re-initializes a package packets, leaving the brch supplied during the CAMALO. The brch argument refers to the micro name and is therfore meaningless to the micro since it will always refers to itself. However, from the VAX the branch indicates which micro is to receive the CAMAC package. Therfore, in this case re-initalizing the brch parameter is of importance. If the optional parameter of brch is provided in the VAX version of CAMALO_RESET, the package brch is reset to the micro name provided, and the package packets are re-initialized, deleting any information added with previous CAMADD's. Otherwise, only the package packets are re-initialized. This routine is useful where the programmer would otherwise call CAMDEL followed by CAMALO, and avoids the expense of releasing and then re-acquiring virtual or dynamic memory.

9.2.10 CAMEXIT Sends a request to the Micro to stop this process's CAMAC activity started with a CAMGO_R request. ISS = CAMEXIT(BRCH) Integer*4 BRCH micro name Note: Process ID is determined from the user's SLCNET interrupt ID number, and may not be the same after a process exits and runs again.


 
Go to top of page
Contact (until Aug. 15, 1996): Jeffrey Miller
Owner: Bob Sass

Converted from VAX Runoff output using doc2webset.pl