
Get_Calo_Pulser     IDNT                      ; Title Get Calorimeter Pulsers.

        SECTION  Sect_Get_Calo_Pulser,4,C     ; Declare a noncommon code
                                              ; section. Align to Longwords.

*****************************************************************************
*                                                                           *
*  Get the Pulser Programming Data for the Calorimeters.                    *
*                                                                           *
*                                                       Rev.  15-JUNE-1992  *
*****************************************************************************

*****************************************************************************
*  Cyclic Section Subroutine   Get the CALORIMETER Pulser Programming Data  *
*                                                                           *
*  Before trying to read the Calorimeter Pulser data via the Vertical       *
*  Interconnect: clear the error flag that records if there has been a bus  *
*  error while trying to read the Calorimeter Pulser Programming Data, and  *
*  change the Bus Error Vector to point to our own Bus Error exception      *
*  handler.   This routing starts at CalBEExHd.                             *
*                                                                           *
*                                                                           *
*  The data returned in the GetCalPulsErr location is the "OR" of all the   *
*  errors that happened will trying to read the pulser programming data.    *
*  If there are no errors then GetCalPulsErr will have a value of zero.     *
*  The table below shows the error value returned from each section.        *
*                                                                           *
*    Error Bit                                                              *
*    Set  Bit#     Bit Value     Section Read that uses this Error Code     *
*    ---------     ---------     --------------------------------------     *
*        0             1         North End Cap Calorimeter Pulsers 0,1      *
*        1             2         Central Calorimeter       Pulsers 2,3      *
*        2             4         South End Cap Calorimeter Pulsers 4,5,6,7  *
*        3             8         Central Calorimeter       Pulsers 8,9      *
*                                                                           *
*        4            16         North End Cap Calorimeter Pulsers A,B      *
*        5            32         South End Cap Calorimeter CETEC Module     *
*        6            64         Central Calorimeter       CETEC Module     *
*        7           128         North End Cap Calorimeter CETEC Module     *
*                                                                           *
*        8           256         ICD Detector              Pulsers C,D      *
*                                                                           *
*        9           512         In-Spill Pedestal Pulser Box               *
*                                                                           *
*****************************************************************************

Begin_Get_Calo_Pulser   CLR.L   GetCalPulsErr      ; Clear the error flag that
                                                   ; shows that there has been
                                                   ; a Bus Error while reading
                                                   ; Calorimeter Pulser
                                                   ; Programming Data.

       MOVE.L  #CalBEExHd,$00000008          ; Point the Bus Error vector
                                             ; to the bus error while reading
                                             ; Calorimeter Pulser Programming
                                             ; Data exception handler.

*****************************************************************************
*  Cyclic Section Subroutine   Get the CALORIMETER Pulser Programming Data  *
*                                                                           *
*  Get the Pulser Programming Data from the 12 Calorimeter Pulsers.         *
*                                                                           *
*  Each Pulser contains 4 VME Words of data.  From each pulser read only    *
*  the 1st and the 3rd word.  Arrange these pulser programming data words   *
*  such that the 1st word is in the high part of a Longword and the 3rd     *
*  word is in the low part of the same Longword.                            *
*                                                                           *
*  If a pulser can not be read then store $0000 for the first word and      *
*  store $F000 for the second word from that pulser.  Dean's note 17-APR-91 *
*                                                                           *
*  Test to see if the pulsers can be read by probing a group at a time.     *
*                                                                           *
*  The starting location in the MVME-214 memory where this routine should   *
*  store the pulser programming data is passed to this routine in reg A0.   *
*                                                                           *
*  Setup the error code for each read section before starting the read.     *
*****************************************************************************

      ;*****  Read North End Cap Calorimeter  Pulsers 0 and 1  *****

       Move.L   #1,ErrorCode            ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   ECNPDBADR+$10,D0         ; Test read of  CALN PLS0  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; CALN PLS0  1st word
          Move.W   ECNPDBADR+$14,(A0)+    ; CALN PLS0  3rd word
          Move.W  ECNPDBADR+$18,(A0)+     ; CALN PLS1  1st word
          Move.W  ECNPDBADR+$1C,(A0)+     ; CALN PLS1  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


      ;*****  Read Central Calorimeter  Pulsers 2 and 3  *****

       Move.L   #2,ErrorCode            ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   CCPDBADR+$0,D0          ; Test read of  CALC PLS2  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; CALC PLS2  1st word
          Move.W   CCPDBADR+$4,(A0)+      ; CALC PLS2  3rd word
          Move.W  CCPDBADR+$18,(A0)+      ; CALC PLS3  1st word
          Move.W  CCPDBADR+$1C,(A0)+      ; CALC PLS3  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


      ;*****  Read South End Cap Calorimeter  Pulsers 4, 5, 6, and 7  *****

       Move.L   #4,ErrorCode            ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W    ECSPDBADR+$10,D0        ; Test read of  CALS PLS4  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; CALN PLS0  1st word
          Move.W  ECSPDBADR+$14,(A0)+     ; CALS PLS4  3rd word
          Move.W  ECSPDBADR+$18,(A0)+     ; CALS PLS5  1st word
          Move.W  ECSPDBADR+$1C,(A0)+     ; CALS PLS5  3rd word
          Move.W  ECSPDBADR+$0,(A0)+      ; CALS PLS6  1st word
          Move.W  ECSPDBADR+$4,(A0)+      ; CALS PLS6  3rd word
          Move.W   ECSPDBADR+$8,(A0)+     ; CALS PLS7  1st word
          Move.W   ECSPDBADR+$C,(A0)+     ; CALS PLS7  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


      ;*****  Read Central Calorimeter  Pulsers 8 and 9  *****

       Move.L   #8,ErrorCode            ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   CCPDBADR+$10,D0         ; Test read of  CALC PLS8  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; CALC PLS8  1st word
          Move.W   CCPDBADR+$14,(A0)+     ; CALC PLS8  3rd word
          Move.W    CCPDBADR+$8,(A0)+     ; CALC PLS9  1st word
          Move.W    CCPDBADR+$C,(A0)+     ; CALC PLS9  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


      ;*****  Read North End Cap Calorimeter  Pulsers A and B  *****

       Move.L   #16,ErrorCode           ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   ECNPDBADR+$0,D0         ; Test read of  CALN PLSA  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W  D0,(A0)+                ; CALN PLSA  1st word
          Move.W  ECNPDBADR+$4,(A0)+      ; CALN PLSA  3rd word
          Move.W   ECNPDBADR+$8,(A0)+     ; CALN PLSB  1st word
          Move.W   ECNPDBADR+$C,(A0)+     ; CALN PLSB  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


*****************************************************************************
*  Cyclic Section Subroutine   Get the CALORIMETER Pulser Programming Data  *
*                                                                           *
*  This section of the routine reads the Pulser Programming Data for the    *
*  ICD Detector.  These are pulsers "C" and "D".   They are read in         *
*  exactly the same way as the Calorimeter Pulsers are read.                *
*                                                                           *
*****************************************************************************

      ;*****  Read ICD Pulsers C and D  *****

       Move.L   #256,ErrorCode          ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   ICDPULSBA+$0,D0         ; Test read of  ICD PLS C  1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; ICD PLS C  1st word
          Move.W   ICDPULSBA+$4,(A0)+     ; ICD PLS C  3rd word
          Move.W  ICDPULSBA+$18,(A0)+     ; ICD PLS D  1st word
          Move.W  ICDPULSBA+$1C,(A0)+     ; ICD PLS D  3rd word
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
          Move.W  #$0000,(A0)+            ; store data that
          Move.W  #$F000,(A0)+            ; indicates an error.
       ENDI


*****************************************************************************
*                                                                           *
*  Now read the In-Spill Pedestal Pulser.   It is read just like a normal   *
*  pulser.  It is addressed as the "3rd" ICD pulser.                        *
*                                                                           *
*  After reading the In-Spill Pedestal Pulser then pack enough memory       *
*  locations to allocate space for 1 more pulsers.  This extra pulser       *
*  does not exist and is not readout at this time.                          *
*                                                                           *
*****************************************************************************

      ;*****  Read the In-Spill Pedestal Pulser  *****

       Move.L   #512,ErrorCode          ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.W   ICDPULSBA+$10,D0        ; Test read In-Spill Pulser 1st word.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.W   D0,(A0)+               ; In-Spill Ped Pulser  1st word.
          Move.W   ICDPULSBA+$14,(A0)+    ; In-Spill Ped Pulser  3rd word.
       ELSE
          Move.W  #$0000,(A0)+            ; If there is a
          Move.W  #$F000,(A0)+            ; Bus Error then
       ENDI

     ;*****  Now reserve enough memory space to hold data from 1 more
     ;*****  Pulser.  Pack this longword location with $0CDF0CDF.

          Move.L  #$0CDF0CDF,(A0)+       ; Reserve memory space for 1 pulser.


*****************************************************************************
*  Cyclic Section Subroutine   Get the CALORIMETER Pulser Programming Data  *
*                                                                           *
*  Get the Programming Data from the 3 calorimeter CETEC modules.           *
*                                                                           *
*  Each CETEC module has 8 longwords of data.  Each CETEC module has a      *
*  base address and continues for the next 7 longwords.                     *
*                                                                           *
*  If a CETEC module can not be read then the high order byte of its first  *
*  longword is filled with F's.                                             *
*                                                                           *
*  Test to see if the CETEC modules can be read by probing them one at a    *
*  time.                                                                    *
*                                                                           *
*  Continue to store data in the MVME-214 at the location pointed to by A0. *
*****************************************************************************

      ;*****  Read South End Cap Calorimeter  CETEC Module  *****

       Move.L   #32,ErrorCode           ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.L   ECSCETEC,D0             ; Test read  EC S CETEC 1st longword.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.L  D0,(A0)+                ; EC South CETEC 1st longword.
          Move.L  ECSCETEC+4,(A0)+        ; EC South CETEC 2nd longword.
          Move.L  ECSCETEC+8,(A0)+        ; EC South CETEC 3rd longword.
          Move.L  ECSCETEC+12,(A0)+       ; EC South CETEC 4th longword.
          Move.L  ECSCETEC+16,(A0)+       ; EC South CETEC 5th longword.
          Move.L  ECSCETEC+20,(A0)+       ; EC South CETEC 6th longword.
          Move.L  ECSCETEC+24,(A0)+       ; EC South CETEC 7th longword.
          Move.L  ECSCETEC+28,(A0)+       ; EC South CETEC 8th longword.
       ELSE
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
       ENDI


      ;*****  Read Central Calorimeter  CETEC Module  *****

       Move.L   #64,ErrorCode           ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.L   CCCETEC,D0             ; Test read  CC CETEC 1st longword.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.L  D0,(A0)+                ; Central Calo CETEC 1st longword.
          Move.L  CCCETEC+4,(A0)+         ; Central Calo CETEC 2nd longword.
          Move.L  CCCETEC+8,(A0)+         ; Central Calo CETEC 3rd longword.
          Move.L  CCCETEC+12,(A0)+        ; Central Calo CETEC 4th longword.
          Move.L  CCCETEC+16,(A0)+        ; Central Calo CETEC 5th longword.
          Move.L  CCCETEC+20,(A0)+        ; Central Calo CETEC 6th longword.
          Move.L  CCCETEC+24,(A0)+        ; Central Calo CETEC 7th longword.
          Move.L  CCCETEC+28,(A0)+        ; Central Calo CETEC 8th longword.
       ELSE
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
       ENDI


      ;*****  Read North End Cap Calorimeter  CETEC Module  *****

       Move.L   #128,ErrorCode          ; Setup error code for this section.

       CLR.L    D1                      ; Clear D1 so that it can
                                        ; receive the local Bus Error flag.

       Move.L   ECNCETEC,D0             ; Test read  EC N CETEC 1st longword.

       IF.B   D1 <EQ> #0   THEN.S         ; If D1 = Zero then no Bus Error.
          Move.L  D0,(A0)+                ; EC North CETEC 1st longword.
          Move.L  ECNCETEC+4,(A0)+        ; EC North CETEC 2nd longword.
          Move.L  ECNCETEC+8,(A0)+        ; EC North CETEC 3rd longword.
          Move.L  ECNCETEC+12,(A0)+       ; EC North CETEC 4th longword.
          Move.L  ECNCETEC+16,(A0)+       ; EC North CETEC 5th longword.
          Move.L  ECNCETEC+20,(A0)+       ; EC North CETEC 6th longword.
          Move.L  ECNCETEC+24,(A0)+       ; EC North CETEC 7th longword.
          Move.L  ECNCETEC+28,(A0)+       ; EC North CETEC 8th longword.
       ELSE
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
          Move.L  #$FF000000,(A0)+        ; If there is a
          Move.L  #$00000000,(A0)+        ; Bus Error then
          Move.L  #$00000000,(A0)+        ; store data that
          Move.L  #$00000000,(A0)+        ; indicates an error.
       ENDI

*****************************************************************************
*  Cyclic Section Subroutine   Get the CALORIMETER Pulser Programming Data  *
*                                                                           *
*  We are finished using the Vertical Interconnect so Restore the           *
*  normal 133A Bug Bus Error Vector and then return to the calling routine. *
*****************************************************************************

       MOVE.L  #$FFF149E2,$00000008          ; Restore normal 133A Bug
                                             ;  Bus Error vector.

       RTS


****************************************************************************
*  CALORIMETER Read Pulser Data Bus Error Exception Handler                *
*                                                                          *
*  Mask the rerun bit in the Special Status Word and set the error while   *
*  reading Calorimeter Pulser Programming Data Error Flag and then return. *
****************************************************************************

           Align   4                       ; Align to long words.

CalBEExHd  MOVE.W  (SP)+,D0                ; pull the Status Register
           MOVE.L  (SP)+,D1                ; pull the Program Counter
           MOVE.W  (SP)+,D2                ; pull the Format - Vector Offset
           MOVE.W  (SP)+,D3                ; pull the Internal Register
           MOVE.W  (SP)+,D4                ; pull the Special Status Register

           ANDI.W  #$FEFF,D4               ; Mask the rerun bus cycle bit

           MOVE.W  D4,-(SP)                ; push the Special Status Register
           MOVE.W  D3,-(SP)                ; push the Internal Register
           MOVE.W  D2,-(SP)                ; push the Format - Vector Offset
           MOVE.L  D1,-(SP)                ; push the Program Counter
           MOVE.W  D0,-(SP)                ; push the Status Register

           Move.L  #$FFFFFFFF,D1           ; Set data reg D1 to F's as a
                                           ; local flag that there has been
                                           ; a Bus Error.

           MOVE.L  GetCalPulsErr,D2        ; "OR" the current Error Code
           OR.L    ErrorCode,D2            ; into the GetCalPulsErr.  This
           MOVE.L  D2,GetCalPulsErr        ; returns to the calling routine
                                           ; the "OR" of all the error codes
                                           ; from all the pulser read sections
                                           ; that suffered bus errors.
           RTE


***************************************************************************
*   Constants Section for  Get Pulser                                     *
*                                                                         *
*  This section defines the base address for reading the Pulsers for      *
*  each of the three Calorimeters, and the Base Address where the Pulser  *
*  Programming Data is stored in the MVME-214 while it is waiting to      *
*  be readout by the VBD.  In addition the externally defined and the     *
*  externally referenced symbols are declared.                            *
***************************************************************************

             Align  4

ErrorCode    DS.L   1               ; Storage location for current error code.

ECNPDBADR    EQU   $12FF1000             ; Cal ECN Pulser Data Base Adrs
CCPDBADR     EQU   $10FF1000             ; Cal CC  Pulser Data Base Adrs
ECSPDBADR    EQU   $11FF1000             ; Cal ECS Pulser Data Base Adrs

ECNCETEC     EQU   $12348000             ; Cal ECN CETEC module Base Adrs
CCCETEC      EQU   $10348000             ; Cal CC  CETEC module Base Adrs
ECSCETEC     EQU   $11348000             ; Cal ECS CETEC module Base Adrs

ICDPULSBA    EQU   $11FF1800             ; ICD Pulser Data Base Adrs


             XDEF   Begin_Get_Calo_Pulser          ; Export this symbol
                                                   ; to other modules.

             XREF   GetCalPulsErr                  ; Import these symbols
                                                   ; which are defined in the
                                                   ; Main_Symbols.Include file.

             END

