1.2. Initializing TEM Hardware

After initializing the software driver the next step is to initialize the GGLT followed by initializing the GTEM.

1.2.1. Initializing the GGLT

Before configuring the GGLT, the GGLT module must be initialized. This is simply done as follows:


  /* init the GGLT module */
  status = ggInit( gg);

Next configure the trigger masks of the GGLT. The following code enables the internal trigger source, while disabling all other trigger sources.


  /* 
     set trigger to disable all trigger sources, except for the
     internal self trigger.  Also make sure the THROTTLE is disabled.
  */
  status = ggSetTrgMask( gg,
			 TRG_DISABLE_THROTTLE | TRG_DISABLE_3_IN_A_ROW | TRG_DISABLE_CAL_HIGH |
			 TRG_DISABLE_CAL_LOW  | TRG_DISABLE_EXT_TRG );

Next configure the bits of the trigger message you wish to send. The following code configures the trigger message to do zero supression, auto range data, no calibration strobe and no TACK signal. The destination and marker are arbitrarily set.


  /* 
     set dynamic part of trigger message 

     default configuration has zero supression turned on and 4range
     data turned off.

  */
  status = ggSetTrgDest( gg, 5);	
  status = ggSetTrg4range( gg, 0);	
  status = ggSetTrgZeroSupress( gg, 1);	
  status = ggSetTrgCalStrb( gg, 0);	
  status = ggSetTrgTACK( gg, 0);	
  status = ggSetTrgMarker( gg, 0);	

Next configure the front end hardware using the GTEM handle.

1.2.2. Initializing the GTEM

Before configuring the GTEM, the GTEM module must be initialized. This is simply done as follows:


  /* init the GTEM module */
  status = gtInit( gt);

The configuration of the GTEM is highly dependent on the subsystem in question. The following code configures the GTEM for taking Calorimeter data. Other subsystems will program the GTEM differently ( see Chapter 2 ).


  /* clear TEM statistics register */
  status = gTEMload( gt, temId, TEM_REG_CMD_RSP_STATS, 0x0);

  /* clear TEM status register */
  status = gTEMload( gt, temId, TEM_REG_STATUS, 0x0);

  /* 
     Configure TEM data masks register

     Default configuration:
       Diagnostic            -- disabled
       CAL Cable Controllers -- enabled
       TKR Cable Controllers -- disabled
  */
  temREG_DataMasks.ui = 0x0;
  temREG_DataMasks.bf.diagnostic = 0;
  temREG_DataMasks.bf.cal = 0x0;
  temREG_DataMasks.bf.tkr = 0xFF;
  status = gTEMload( gt, temId, TEM_REG_DATA_MASKS, temREG_DataMasks.ui);

  /* large TEM timeout */
  temREG_Config.ui = 0x0;
  temREG_Config.bf.cableTimeout = 0xFFF;
  status = gTEMload( gt, temId, TEM_REG_CONFIGURATION, temREG_Config.ui);

  /* enable output in our GCCCs */
  gcccREG_Config.ui = 0x0;
  gcccREG_Config.bf.controllerOutEnable = 1;
  status = gGCCCload( gt, temId, BROADCAST_ADDRESS, GCCC_REG_CONFIGURATION, gcccREG_Config.ui);

  /* disable all GCRCs in all GCCCs */
  status = gGCCCload( gt, temId, BROADCAST_ADDRESS, GCCC_REG_LAYER_MASK_0, 0xFFFFFFFF);
  status = gGCCCload( gt, temId, BROADCAST_ADDRESS, GCCC_REG_LAYER_MASK_1, 0xFFFFFFFF);

  /* large timeouts for all GCCCs */
  gcccREG_EventTimeouts.ui = 0x0;
  gcccREG_EventTimeouts.bf.timeout = 0x3FF;
  status = gGCCCload( gt, temId, BROADCAST_ADDRESS, GCCC_REG_EVENT_TIMEOUTS, gcccREG_EventTimeouts.ui);