#include "c1190Lib.h" extern int Nc1190; /* CAEN 1190/1290 specific definitions */ int caen1290_download(){ int ii; int Nc1190 = 6; int res = 1; tdc1190Init(0x11180000,0x80000,6,0); printf("\n"); printf(BOLDBLUE "Number of CAEN1290 TDC initialized = %d \n" RESET, Nc1190); printf("\n"); for(ii = 0; ii < Nc1190; ii++) tdc1190Clear(ii); for(ii = 0; ii < Nc1190; ii++) tdc1190Reset(ii); for(ii = 0; ii < Nc1190; ii++) { /* program TDC for trigger matching mode */ tdc1190SetTriggerMatchingMode(ii); /* set Trigger Window Width (ns) */ tdc1190SetWindowWidth(ii, caen1290[3].window_width); /* set Trigger Window Offset (ns) */ tdc1190SetWindowOffset(ii, caen1290[3].window_offset); /* set Extra Search Margin (after window) (ns) */ tdc1190SetExtraSearchMargin(ii, caen1290[3].window_extra); /* set Reject Margin (before window) (ns) */ tdc1190SetRejectMargin(ii, caen1290[3].window_reject); /* enable subtraction of trigger time */ tdc1190EnableTriggerTimeSubtraction(ii); /* set Edge Detection */ tdc1190SetEdgeDetectionConfig(ii, caen1290[3].edge); /* set Channels Enable Mask */ // tdc1290EnableChannels(ii, tdc[ii].mask); tdc1190EnableChannels(ii, 0xFFFF); /* set Readout settings */ tdc1190EventFifo(ii, caen1290[3].berr_fifo); tdc1190BusError(ii, (~caen1290[3].berr_fifo)&0x1); /* enable 64-bit alignment */ /* NOTE: 64-bit alignment must be enabled for any DMA readout, not only for MBLT(D64) but for BLT(D32) as well; some DMA engines (for example the one on mv5100) will cut off last 32-bit word if it is not even, for example if event size is equal to 137 D32 words, only 136 D32 words will be transfered */ /* in addition universe library contains check for 64-bit alignment in dmastart procedure, it will return error if ... */ tdc1190Align64(ii, 1); /* set BLT Event Number Register */ tdc1190SetBLTEventNumber(ii, caen1290[3].blt_Events); /* set Max Number of Hits per Event */ tdc1190SetMaxNumberOfHitsPerEvent(ii, caen1290[3].n_Hits); /* reset MCST flag in every board in case if it was set before */ tdc1190ResetMCST(ii); /* set 'almost full' level */ tdc1190SetAlmostFullLevel(ii, caen1290[3].almostFullLevel); /* program output connector to signal on it */ tdc1190SetOutProg(ii,caen1290[3].outProgControl); } // Print out settings printf("\n"); printf(" SASCHA Print out settings \n"); printf("\n"); tdc1190ReadTriggerConfiguration(5); printf("\n"); tdc1190ReadEdgeDetectionConfig(5); res = tdc1190GetEdgeResolution(5); printf(" Resolution = %d ps\n",res); res = tdc1190ReadAcquisitionMode(5); if(res==0) printf(" Acquisition Mode = Continuous Storage\n"); else printf(" Acquisition Mode = Trigger Matching\n"); tdc1190Status(5); return(0); }