Rev 2159 Rev 2160
Line 1... Line 1...
1 #include "main.h" 1 #include "main.h"
2 #include <math.h> 2 #include <math.h>
3   -  
4 #use fast_io (D) 3 #include "GP2.h"
5   4  
6 #define VERSION 0.2 5 #define VERSION 0.2
7   6  
8 #define START PIN_D4 -  
9 #define STOP1 PIN_D5 -  
10 #define STOP2 PIN_D7 -  
11   -  
12 #include "GP2.h" -  
13   -  
14 #define ONE_WIRE_PIN PIN_E2 7 #define ONE_WIRE_PIN PIN_E2
15 #include "ds1820.c" 8 #include "ds1820.c"
16   9  
17 void main() 10 void main()
18 { 11 {
19   -  
20 /* setup_adc_ports(NO_ANALOGS|VSS_VDD); // for PIC18F4550 -  
21 setup_adc(ADC_CLOCK_DIV_2); -  
22 setup_psp(PSP_DISABLED); -  
23 setup_spi(SPI_SS_DISABLED); -  
24 setup_wdt(WDT_OFF); -  
25 setup_timer_0(RTCC_INTERNAL); -  
26 setup_timer_1(T1_DISABLED); -  
27 setup_timer_2(T2_DISABLED,0,1); -  
28 setup_ccp1(CCP_OFF); -  
29 setup_comparator(NC_NC_NC_NC); -  
30 setup_vref(FALSE); -  
31 */ -  
32 setup_adc_ports(NO_ANALOGS|VSS_VDD); 12 setup_adc_ports(NO_ANALOGS|VSS_VDD);
33 setup_adc(ADC_CLOCK_DIV_2); 13 setup_adc(ADC_CLOCK_DIV_2);
34 setup_spi(SPI_SS_DISABLED); 14 setup_spi(SPI_SS_DISABLED);
35 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 15 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
36 setup_timer_1(T1_DISABLED); 16 setup_timer_1(T1_DISABLED);
37 setup_timer_2(T2_DISABLED,0,1); 17 setup_timer_2(T2_DISABLED,0,1);
38 setup_ccp1(CCP_OFF); 18 setup_ccp1(CCP_OFF);
39 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard 19 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
40   20  
41 set_tris_d(0x00); -  
42   -  
43 TDC_reset(); 21 TDC_reset();
44   22  
45 output_low(START); -  
46 output_low(STOP1); -  
47 output_low(STOP2); -  
48   -  
49 delay_ms(50); 23 delay_ms(50);
50   24  
51 int16 ret16; 25 int16 ret16;
52 int8 ret8; 26 int8 ret8;
53   27  
Line 82... Line 56...
82 delay_ms(50); 56 delay_ms(50);
83 57
84 TDC_start_cycle(); 58 TDC_start_cycle();
85 59
86 delay_ms(200); 60 delay_ms(200);
87 -  
88 output_high(STOP2); // Merime jenom jednim kanalem (druhy zrejme byt v H) -  
89 61
90 output_high(START); -  
91 output_low(START); -  
92 delay_us(150); -  
93 -  
94 output_high(STOP1); -  
95 output_low(STOP1); -  
96 delay_us(1); -  
97 -  
98 output_high(STOP1); -  
99 output_low(STOP1); -  
100 delay_us(10); -  
101 -  
102 output_high(STOP1); -  
103 output_low(STOP1); -  
104 delay_us(1); -  
105 -  
106 //----------------------------------------------- Pocitani 62 //----------------------------------------------- Pocitani
107   63  
108 // printf("Time2: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); 64 // printf("Time2: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4));
109   65  
110 66
Line 139... Line 95...
139   95  
140   96  
141 //----------------------------------------------- Mereni 1 97 //----------------------------------------------- Mereni 1
142 98
143 TDC_init(); 99 TDC_init();
144 -  
145 delay_ms(50); -  
146 output_low(START); -  
147 output_low(STOP1); -  
148 output_low(STOP2); -  
149 -  
150 output_high(START); // start of time measurement -  
151   -  
152 output_high(STOP2); -  
153 output_high(STOP1); -  
154 -  
155 output_low(STOP1); -  
156 output_low(STOP2); -  
157 output_low(START); -  
158   -  
159   -  
160   100  
161 //----------------------------------------------- Pocitani 101 //----------------------------------------------- Pocitani
162   102  
163 // printf("Time1: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); 103 // printf("Time1: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4));
164   104