## Set addresses
##################################################
merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_trb3.db $USER_DIR/db/addresses_trb3.db
+#merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_trb3sc.db $USER_DIR/db/addresses_trb3sc.db
merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_dirich.db $USER_DIR/db/addresses_dirich.db
merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_dirich_concentrator.db $USER_DIR/db/addresses_dirich_concentrator.db
-
+merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_farich_concentrator.db $USER_DIR/db/addresses_farich_concentrator.db
+merge_serial_address.pl $DAQ_TOOLS_PATH/base/serials_farich.db $USER_DIR/db/addresses_farich.db
#echo "disable port 6 on hub 0x8841"
-#trbcmd clearbit 0x8841 0xc0 0x60
-#trbcmd clearbit 0x8841 0xc1 0x60
-#trbcmd clearbit 0x8841 0xc3 0x60
-#trbcmd w 0xc001 0xc0 0xe2
-#trbcmd w 0xc001 0xc1 0xe2
-#trbcmd w 0xc001 0xc3 0xe2
-
-#echo "disable port 4 on hub 0x8841"
-#trbcmd clearbit 0x8841 0xc0 0x10
-#trbcmd clearbit 0x8841 0xc1 0x10
-#trbcmd clearbit 0x8841 0xc3 0x10
+#trbcmd clearbit 0x8841 0xc0 0x40
+#trbcmd clearbit 0x8841 0xc1 0x40
+#trbcmd clearbit 0x8841 0xc3 0x40
echo "GbE settings"
loadregisterdb.pl db/register_configtdc.db
echo "TDC settings end"
-
-
# setup central FPGA - enable peripherial signals
#switchport.pl 0x8841 6 off
-
+# remove reset
+#trbcmd clearbit 0x16f7 0xcd00 0x1
#Dirich-Concentrator: enable reference time from RJ45
######trbcmd loadbit 0x8300 0xd580 0x6 0x6
-#trbcmd w 0x8300 0xd580 0x4
-
-#trbcmd loadbit 0xfe52 0xd580 0x6 0x2
-#trbcmd loadbit 0xfe52 0xd580 0x6 0x0
+echo "pulser"
+# pulser #0 to 10 kHz
+trbcmd w 0xc001 0xa154 0x0000270f
+#trbcmd w 0xc001 0xa150 0x0022270f
echo "trigger type"
# set trigger type to 0x1
-trbcmd w 0xc001 0xa15e 0x11111d11
+trbcmd setbit 0xc001 0xa15c 0x10
+
#trbcmd clearbit 0x1130 0xc801 0x80000000 # disable window
#trbcmd w 0x1130 0xc802 0xffff0000 # enable upper 16 channels for padiwa
#trbcmd w 0x1580 0xc802 0xffffffff # enable upper 16 channels for padiwa
-cd ~/trbsoft/daqtools/xml-db
-./put.pl Readout 0xfe51 SetMaxEventSize 500
-cd $USER_DIR
-
-trbcmd w 0xfe51 0xdf80 0xffffffff # enable monitor counters
+#cd ~/trbsoft/daqtools/xml-db
+#./put.pl Readout 0x16eb SetMaxEventSize 500
+#cd $USER_DIR
-#trbcmd w 0x1133 0xc804 0x7c # max number of words
-trbcmd clearbit 0x1133 0xc801 0x80000000 # disable window
-
-# turn off 4 dirich without ref-time
-#~/trbsoft/daqtools/tools/switchport.pl 0x8841 3 off 3
-#~/trbsoft/daqtools/tools/switchport.pl 0x8841 3 off 1
-#~/trbsoft/daqtools/tools/switchport.pl 0x8841 3 off 0
+#trbcmd w 0xfe51 0xdf80 0xffffffff # enable monitor counters
+#trbcmd w 0x1133 0xc804 0x11e18 # Erazor TDC
+#trbcmd w 0x1130 0xc804 0x11e18 # Erazor TDC
+#trbcmd clearbit 0x1133 0xc801 0x80000000 # disable window
+#trbcmd clearbit 0x1130 0xc801 0x80000000 # disable window
+#trbcmd w 0x1130 0xc802 0x80000000
+#trbcmd w 0x1130 0xc803 0x00000000
#trbcmd w 0x1133 0xc802 0x00000c03 # enable pulser
#trbcmd setbit 0xc001 0xa101 0x8 # enable external trigger in of CTS
-trbcmd w 0xfe51 0xc804 0xa
-echo "pulser"
-# pulser #0 to 10 kHz
-trbcmd w 0xc001 0xa156 0x00000270f
-trbcmd w 0xc001 0xa157 0x00002270f
-###trbcmd w 0xc001 0xa150 0x0022270f
+echo "pulser frequency"
+trbcmd w 0xc001 0xa154 0x3e7 # Pulser 1: 100kHz
+trbcmd w 0xc001 0xa155 0x3e7 # Pulser 2: 100kHz
-echo "pulser enable"
-### pulser enable
-#trbcmd setbit 0xc001 0xa101 0x6
+./tdcv4_caltrg_init.sh
-#trbcmd setbit 0xc001 0xa101 0x16 # pulser, external + internal calibration
-trbcmd setbit 0xc001 0xa101 0x2 # pulser, external + internal calibration
-# sets for TDCv4 ringbuffer threshold etc.
-trbcmd w 0x1133 0xc804 0x11e18
-exit
+trbcmd setbit 0xfe53 0xcd00 0x08000000 # enable TDL of RefChan
+#trbcmd w 0xfe53 0xcd12 0x2801 # enable channels
+#trbcmd w 0xfe53 0xcd22 0x8002 # enable channels
+trbcmd clearbit 0xfe53 0xcd00 0x1
-# setup for TRB3-Test
-trbcmd w 0xfe4c 0xc802 0xffffffff
-trbcmd w 0xfe4c 0xc803 0x0000ffff
+# set Oscillator frequency
+trbcmd loadbit 0xfe53 0xcd24 0xff000000 0x60000000 # 8 LSBs of oscillator frequency in units of 10kHz
+trbcmd loadbit 0xfe53 0xcd25 0xff000000 0x6d000000 # 8 MSBs of oscillator frequency in units of 10kHz
-~/trbsoft/daqtools/padiwa.pl 0xfe4c 0 invert 0xffff
-~/trbsoft/daqtools/padiwa.pl 0xfe4c 1 invert 0xffff
-~/trbsoft/daqtools/padiwa.pl 0xfe4c 2 invert 0xffff
+#enable Hitcounters TDCv4
+trbcmd setbit 0xfe53 0xcd00 0x200
+trbcmd clearbit 0xfe53 0xcd00 0x100
+
+
+# Stretcher
+trbcmd loadbit 0xfe53 0xcd17 0xffff 0xffff # enable Stretcher for Channels 15..0
+trbcmd loadbit 0xfe53 0xcd27 0xffff 0xffff # enable Stretcher for Channels 31..16
+trbcmd setbit 0xfe53 0xcd00 0x40000000 # enable Stretcher for Reference Channel
+
+# Enable
+#./tdcv4_enable_channels.sh 0xfe53 0x11 0x0 #enable channel 5 and 0
+./tdcv4_enable_channels.sh 0xfe53 0xf 0xf #enable channel 5 and 0
+
+echo "pulser enable"
+#trbcmd setbit 0xc001 0xa101 0x2
+# pulser enable