Line 45... |
Line 45... |
45 |
*/ |
45 |
*/ |
46 |
|
46 |
|
47 |
int16 ret16; |
47 |
int16 ret16; |
48 |
int8 ret8; |
48 |
int8 ret8; |
49 |
|
49 |
|
50 |
|
- |
|
51 |
while(TRUE) |
- |
|
52 |
{ |
- |
|
53 |
delay_ms(100); |
- |
|
54 |
TDC_reset(); |
50 |
TDC_reset(); |
55 |
delay_ms(100); |
51 |
delay_ms(100); |
56 |
|
52 |
|
57 |
//----------------------------------------------- Nastaveni registru |
53 |
//----------------------------------------------- Nastaveni registru |
58 |
hit1=TDC_MRANGE2_HIT1_START; |
54 |
hit1=TDC_MRANGE2_HIT1_START; |
59 |
hitin1=TDC_HITIN1_4; |
55 |
hitin1=TDC_HITIN1_4; |
60 |
hitin2=TDC_HITIN2_0; |
56 |
hitin2=TDC_HITIN2_0; |
61 |
en_int= TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT; |
57 |
en_int= TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT; |
62 |
en_err_val=TDC_ERRVAL_EN; |
58 |
en_err_val=TDC_ERRVAL_EN; |
- |
|
59 |
clkhsdiv=TDC_CLKHSDIV_4; |
63 |
delval1=0x0; |
60 |
delval1=0x0; |
64 |
delval2=0x0; |
61 |
delval2=0x0; |
65 |
delval3=0x0; |
62 |
delval3=0x0; |
66 |
|
63 |
|
67 |
TDC_update_registers(); |
64 |
TDC_update_registers(); |
68 |
|
65 |
|
69 |
//----------------------------------------------- Vypis registru |
- |
|
70 |
|
66 |
while(TRUE) |
71 |
printf("- %LX %LX %LX %LX ", TDC_get_measurement(0), TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3)); |
- |
|
72 |
|
67 |
{ |
73 |
output_low(TDC_ENABLE); |
- |
|
74 |
ret8=0; |
68 |
delay_ms(100); |
75 |
ret8=(0b1011<<4)|4; |
- |
|
76 |
spi_xfer(TDC_stream,ret8,8); |
- |
|
77 |
ret16=spi_xfer(TDC_stream,0,16); |
- |
|
78 |
output_high(TDC_ENABLE); |
- |
|
79 |
printf("[%Lu %Lu %Lu %Lu %Lu %Lu %Lu] ", (1&(ret16)>>12), (1&(ret16)>>11), (1&(ret16)>>10), 1&(ret16)>>9, 7&(ret16)>>6, 7&(ret16)>>3, 7&ret16); |
- |
|
80 |
|
- |
|
81 |
printf("%X\r\n",TDC_get_reg1()); |
- |
|
82 |
|
69 |
|
83 |
//----------------------------------------------- Mereni |
70 |
//----------------------------------------------- Mereni |
84 |
|
71 |
|
85 |
TDC_init(); |
72 |
TDC_init(); |
86 |
|
73 |
|
Line 92... |
Line 79... |
92 |
|
79 |
|
93 |
output_high(STOP2); // Merime jenom jednim kanalem (druhy zrejme musi byt v H) |
80 |
output_high(STOP2); // Merime jenom jednim kanalem (druhy zrejme musi byt v H) |
94 |
|
81 |
|
95 |
output_high(START); |
82 |
output_high(START); |
96 |
output_low(START); |
83 |
output_low(START); |
97 |
delay_us(15); |
84 |
delay_us(150); |
98 |
|
85 |
|
99 |
output_high(STOP1); |
86 |
output_high(STOP1); |
100 |
output_low(STOP1); |
87 |
output_low(STOP1); |
101 |
delay_us(1); |
88 |
delay_us(1); |
102 |
|
89 |
|
103 |
|
- |
|
104 |
output_high(STOP1); |
90 |
output_high(STOP1); |
105 |
output_low(STOP1); |
91 |
output_low(STOP1); |
106 |
delay_us(10); |
92 |
delay_us(10); |
107 |
|
93 |
|
108 |
output_high(STOP1); |
94 |
output_high(STOP1); |
109 |
output_low(STOP1); |
95 |
output_low(STOP1); |
110 |
delay_us(1); |
96 |
delay_us(1); |
111 |
|
97 |
|
112 |
|
- |
|
113 |
|
- |
|
114 |
//----------------------------------------------- Pocitani |
98 |
//----------------------------------------------- Pocitani |
115 |
|
99 |
|
116 |
printf(" %3.7f %3.7f %3.7f ", TDC_mrange2_get_time(1), TDC_mrange2_get_time(2), TDC_mrange2_get_time(3)); |
100 |
printf("Time: %3.7f %3.7f %3.7f ", TDC_mrange2_get_time(1), TDC_mrange2_get_time(2), TDC_mrange2_get_time(3)); |
117 |
|
101 |
|
118 |
output_low(TDC_ENABLE); //status register |
102 |
output_low(TDC_ENABLE); //status register |
119 |
ret8=0; |
103 |
ret8=0; |
120 |
ret8=(0b1011<<4)|4; |
104 |
ret8=(0b1011<<4)|4; |
121 |
spi_xfer(TDC_stream,ret8,8); |
105 |
spi_xfer(TDC_stream,ret8,8); |
122 |
ret16=spi_xfer(TDC_stream,0,16); |
106 |
ret16=spi_xfer(TDC_stream,0,16); |
123 |
output_high(TDC_ENABLE); |
107 |
output_high(TDC_ENABLE); |
124 |
printf("[%Lu %Lu %Lu %Lu %Lu %Lu %Lu] ", (1&(ret16)>>12), (1&(ret16)>>11), (1&(ret16)>>10), 1&(ret16)>>9, 7&(ret16)>>6, 7&(ret16)>>3, 7&TDC_get_status()); |
108 |
printf("[%Lu %Lu %Lu %Lu %Lu %Lu %Lu]\r\n", (1&(ret16)>>12), (1&(ret16)>>11), (1&(ret16)>>10), 1&(ret16)>>9, 7&(ret16)>>6, 7&(ret16)>>3, 7&TDC_get_status()); |
125 |
|
109 |
|
- |
|
110 |
TDC_start_temp(); |
- |
|
111 |
output_low(TDC_ENABLE); //status register |
- |
|
112 |
ret8=0; |
- |
|
113 |
ret8=(0b1011<<4)|4; |
126 |
printf("%X\r\n",TDC_get_reg1()); |
114 |
spi_xfer(TDC_stream,ret8,8); |
- |
|
115 |
ret16=spi_xfer(TDC_stream,0,16); |
- |
|
116 |
output_high(TDC_ENABLE); |
- |
|
117 |
printf("Temp: [%Lu %Lu %Lu %Lu %Lu %Lu %Lu] ", (1&(ret16)>>12), (1&(ret16)>>11), (1&(ret16)>>10), 1&(ret16)>>9, 7&(ret16)>>6, 7&(ret16)>>3, 7&TDC_get_status()); |
- |
|
118 |
printf(" %LX %LX %LX %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); |
127 |
|
119 |
|
128 |
} |
120 |
} |
129 |
} |
121 |
} |