Rev 1775 Rev 1798
Line 26... Line 26...
26 setup_comparator(NC_NC_NC_NC); 26 setup_comparator(NC_NC_NC_NC);
27 setup_vref(FALSE); 27 setup_vref(FALSE);
28   28  
29 TDC_reset(); 29 TDC_reset();
30 30
31 MRange=TDC_MRANGE1; 31 /* MRange=TDC_MRANGE1;
32 hitin1=TDC_HITIN1_2; 32 hitin1=TDC_HITIN1_1;
33 hitin2=TDC_HITIN2_2; 33 hitin2=TDC_HITIN2_0;
34 hit1=TDC_MRANGE1_HIT1_START; 34 hit1=TDC_MRANGE1_HIT1_START;
35 hit2=TDC_MRANGE1_HIT2_2CH1; 35 hit2=TDC_MRANGE1_HIT2_1CH1;
36 en_int= (TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT); 36 en_int=0x0; // (TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT);
37 en_err_val=TDC_ERRVAL_EN; 37 en_err_val=TDC_ERRVAL_EN;
38 delval1=0x0; 38 delval1=0x0;
39 delval2=0x0; 39 delval2=0x0;
40 delval3=0x0; 40 delval3=0x0;
41 calibrate=TDC_CALIBRATE_EN; 41 calibrate=TDC_CALIBRATE_DIS;
42 disautocal=TDC_AUTOCAL_EN; 42 disautocal=TDC_AUTOCAL_EN;
43 43
44 firenum=TDC_FIRENUM_2; 44 firenum=TDC_FIRENUM_0;
45 div_fire=TDC_DIV_FIRE_3; 45 div_fire=TDC_DIV_FIRE_2;
-   46
-   47 Tcycle=TDC_TCYSLE_LONG;
-   48 portnum=TDC_TPORTNUM_2;
-   49 fakenum=TDC_TFAKENUM_2;
46 50
47 TDC_update_registers(); 51 TDC_update_registers();
48 52 */
49 output_low(START); 53 output_low(START);
50 output_low(STOP1); 54 output_low(STOP1);
51 output_low(STOP2); 55 output_low(STOP2);
52 56
53 TDC_start_cal_resonator(); 57 TDC_start_cal_resonator();
Line 56... Line 60...
56 TDC_start_cal(); 60 TDC_start_cal();
57 delay_ms(50); 61 delay_ms(50);
58 62
59 while(true) 63 while(true)
60 { 64 {
61 temperature = ds1820_read(); 65 temperature = ds1820_read();
-   66 TDC_reset();
-   67 hitin1=TDC_HITIN1_2;
-   68 hitin2=TDC_HITIN2_1;
-   69 en_err_val=1;
-   70 TDC_update_registers();
62   71  
-   72 delay_ms(50);
63 TDC_init(); 73 TDC_init();
-   74
64 delay_ms(50); 75 delay_ms(50);
65 printf("Temp: %f \r\n", temperature); 76 printf("Temp: %f \r\n", temperature);
66 delay_ms(50); 77 delay_ms(50);
67 printf("status: %LX \r\n", TDC_get_status()); 78 printf("status: %LX \r\n", TDC_get_status());
68   79  
69 TDC_start_cycle(); 80 // TDC_start_cycle();
70   81  
71 delay_us(10); 82 delay_us(10);
72 output_high(START); 83 output_high(START);
73 // delay_us(1); 84 // delay_us(1);
74 output_low(START); -  
75 85
76 // delay_us(1); 86 delay_us(10);
-   87 output_low(START);
77 88
78 output_high(STOP1); 89 // output_high(STOP1);
79 // delay_us(10); 90 // delay_us(10);
80 output_low(STOP1); -  
81 // delay_us(500); 91 // delay_us(500);
82 // output_high(STOP1); 92 // output_high(STOP1);
83 // delay_us(10); 93 // delay_us(10);
84 // output_low(STOP1); 94 // output_low(STOP1);
85 // delay_us(500); 95 // delay_us(500);
86 // output_high(STOP1); 96 // output_high(STOP1);
87 // delay_us(10); 97 // delay_us(10);
88 // output_low(STOP1); 98 // output_low(STOP1);
-   99 output_low(START);
89   100  
90 output_high(STOP2); 101 // output_high(STOP2);
91 // delay_us(10); 102 // delay_us(10);
-   103 // output_low(START);
-   104 // output_low(STOP1);
92 output_low(STOP2); 105 // output_low(STOP2);
93 // delay_us(500); 106 // delay_us(500);
94 output_high(STOP2); 107 // output_high(STOP2);
95 // delay_us(10); 108 // delay_us(10);
96 output_low(STOP2); 109 // output_low(STOP2);
97 // delay_us(500); 110 // delay_us(500);
98 output_high(STOP2); 111 // output_high(STOP2);
99 // delay_us(10); 112 // delay_us(10);
100 output_low(STOP2); 113 // output_low(STOP2);
101   114  
-   115  
-   116 // delay_ms(10);
102 output_low(START); 117 // TDC_start_temp();
103   118  
104 delay_ms(10); 119 delay_ms(10);
105 printf("status: %LX \r\n", TDC_get_status()); 120 printf("status: %LX \r\n", TDC_get_status());
106 delay_ms(50); 121 delay_ms(50);
107 printf("measured: %LX, %LX, %LX, %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); 122 printf("measured: %LX, %LX, %LX, %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4));