Rev 1965 Rev 1966
Line 96... Line 96...
96 unsigned int32 TDC_get_measurement(int num) 96 unsigned int32 TDC_get_measurement(int num)
97 { 97 {
98 unsigned int32 ret; 98 unsigned int32 ret;
99   99  
100 output_low(TDC_ENABLE); 100 output_low(TDC_ENABLE);
101 spi_xfer(TDC_stream,0xB0 + num - 1, 8); 101 spi_xfer(TDC_stream,0xB0 + num, 8);
102 ret=spi_xfer(TDC_stream,0,32); 102 ret=spi_xfer(TDC_stream,0,32);
103 output_high(TDC_ENABLE); 103 output_high(TDC_ENABLE);
104 return ret; 104 return ret;
105 } 105 }
106   106  
Line 200... Line 200...
200 output_high(TDC_ENABLE); 200 output_high(TDC_ENABLE);
201 } 201 }
202   202  
203 float TDC_mrange2_get_time(unsigned int shot) 203 float TDC_mrange2_get_time(unsigned int shot)
204 { 204 {
-   205 unsigned int32 measurement;
-   206 float time;
-   207  
205 switch (shot) 208 switch (shot)
206 { 209 {
207 case 1: 210 case 1:
208 hit2=TDC_MRANGE2_HIT2_1CH1; 211 hit2=TDC_MRANGE2_HIT2_1CH1;
209 break; 212 break;
210   213  
211 case 2: 214 case 2:
212 hit2=TDC_MRANGE2_HIT2_2CH1; 215 hit2=TDC_MRANGE2_HIT2_2CH1;
213 break; 216 break;
214   217  
215 case 3: 218 case 3:
216 hit2=TDC_MRANGE2_HIT2_3CH1; 219 hit2=TDC_MRANGE2_HIT2_3CH1;
217 break; 220 break;
218 } 221 }
-   222 TDC_update_reg1(); // tell to ALU which shot period must be computed
-   223
-   224 Delay_ms(50); // wait to computing of result
-   225
-   226 measurement=TDC_get_measurement(7&TDC_get_status()); // read computed value on pointer result register address
-   227
-   228  
-   229 switch (clkhsdiv)
-   230 {
-   231 case TDC_CLKHSDIV_1:
-   232 time=(measurement/65536.0) * 1.0e6/TDC_CLKHS;
-   233 break;
-   234  
-   235 case TDC_CLKHSDIV_2:
-   236 time=(measurement/65536.0) * 1.0e6/TDC_CLKHS * 2.0;
-   237 break;
-   238  
-   239 case TDC_CLKHSDIV_4:
-   240 time=(measurement/65536.0) * 1.0e6/TDC_CLKHS * 4.0;
-   241 break;
-   242 case TDC_CLKHSDIV_8:
-   243 time=(measurement/65536.0) * 1.0e6/TDC_CLKHS * 8.0;
219 TDC_update_reg1(); 244 break;
-   245 }
-   246 return time;
220 } 247 }