Line 51... |
Line 51... |
51 |
TDC_update_registers(); |
51 |
TDC_update_registers(); |
52 |
*/ |
52 |
*/ |
53 |
output_low(START); |
53 |
output_low(START); |
54 |
output_low(STOP1); |
54 |
output_low(STOP1); |
55 |
output_low(STOP2); |
55 |
output_low(STOP2); |
- |
|
56 |
|
- |
|
57 |
delay_ms(50); |
56 |
|
58 |
|
- |
|
59 |
//write raw register values |
- |
|
60 |
output_low(TDC_ENABLE); |
- |
|
61 |
spi_xfer(TDC_stream,0x80338AE8,32); |
- |
|
62 |
output_high(TDC_ENABLE); |
- |
|
63 |
|
- |
|
64 |
output_low(TDC_ENABLE); |
- |
|
65 |
spi_xfer(TDC_stream,0x81211400,32); |
- |
|
66 |
output_high(TDC_ENABLE); |
- |
|
67 |
|
- |
|
68 |
output_low(TDC_ENABLE); |
- |
|
69 |
spi_xfer(TDC_stream,0x82E03200,32); |
- |
|
70 |
output_high(TDC_ENABLE); |
- |
|
71 |
|
- |
|
72 |
output_low(TDC_ENABLE); |
- |
|
73 |
spi_xfer(TDC_stream,0x83083300,32); |
- |
|
74 |
output_high(TDC_ENABLE); |
- |
|
75 |
|
- |
|
76 |
output_low(TDC_ENABLE); |
- |
|
77 |
spi_xfer(TDC_stream,0x84203400,32); |
- |
|
78 |
output_high(TDC_ENABLE); |
- |
|
79 |
|
- |
|
80 |
output_low(TDC_ENABLE); |
- |
|
81 |
spi_xfer(TDC_stream,0x85080000,32); |
- |
|
82 |
output_high(TDC_ENABLE); |
- |
|
83 |
|
57 |
TDC_start_cal_resonator(); |
84 |
TDC_start_cal_resonator(); |
58 |
delay_ms(50); |
85 |
delay_ms(50); |
59 |
printf("calibrate: %LX, %LX, %LX, %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); |
86 |
printf("calibrate: %LX, %LX, %LX, %LX \r\n", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); |
60 |
TDC_start_cal(); |
87 |
// TDC_start_cal(); |
61 |
delay_ms(50); |
88 |
// delay_ms(50); |
62 |
|
89 |
|
63 |
while(true) |
90 |
while(true) |
64 |
{ |
91 |
{ |
65 |
temperature = ds1820_read(); |
92 |
temperature = ds1820_read(); |
66 |
TDC_reset(); |
93 |
|
67 |
hitin1=TDC_HITIN1_2; |
- |
|
68 |
hitin2=TDC_HITIN2_1; |
- |
|
69 |
en_err_val=1; |
- |
|
70 |
TDC_update_registers(); |
- |
|
71 |
|
- |
|
72 |
delay_ms(50); |
- |
|
73 |
TDC_init(); |
94 |
TDC_init(); |
74 |
|
95 |
|
75 |
delay_ms(50); |
96 |
delay_ms(50); |
76 |
printf("Temp: %f \r\n", temperature); |
97 |
printf("Temp: %f \r\n", temperature); |
77 |
delay_ms(50); |
98 |
delay_ms(50); |
78 |
printf("status: %LX \r\n", TDC_get_status()); |
99 |
printf("status: %LX \r\n", TDC_get_status()); |
79 |
|
100 |
|
80 |
// TDC_start_cycle(); |
101 |
TDC_start_cycle(); |
81 |
|
102 |
|
82 |
delay_us(10); |
103 |
// delay_us(10); |
83 |
output_high(START); |
104 |
output_high(START); |
84 |
// delay_us(1); |
105 |
// delay_us(1); |
85 |
|
106 |
|
86 |
delay_us(10); |
107 |
delay_us(100); |
87 |
output_low(START); |
108 |
// output_low(START); |
88 |
|
109 |
|
89 |
// output_high(STOP1); |
110 |
output_high(STOP1); |
90 |
// delay_us(10); |
111 |
// delay_us(10); |
91 |
// delay_us(500); |
112 |
// delay_us(500); |
92 |
// output_high(STOP1); |
113 |
// output_high(STOP1); |
93 |
// delay_us(10); |
114 |
// delay_us(10); |
94 |
// output_low(STOP1); |
115 |
output_low(STOP1); |
95 |
// delay_us(500); |
116 |
// delay_us(500); |
96 |
// output_high(STOP1); |
117 |
// output_high(STOP1); |
97 |
// delay_us(10); |
118 |
delay_us(10); |
98 |
// output_low(STOP1); |
119 |
// output_low(STOP1); |
99 |
output_low(START); |
120 |
output_low(START); |
100 |
|
121 |
|
101 |
// output_high(STOP2); |
122 |
// output_high(STOP2); |
102 |
// delay_us(10); |
123 |
// delay_us(10); |
103 |
// output_low(START); |
124 |
// output_low(START); |
104 |
// output_low(STOP1); |
125 |
output_high(STOP1); |
105 |
// output_low(STOP2); |
126 |
// output_low(STOP2); |
106 |
// delay_us(500); |
127 |
// delay_us(500); |
107 |
// output_high(STOP2); |
128 |
// output_high(STOP2); |
108 |
// delay_us(10); |
129 |
// delay_us(10); |
109 |
// output_low(STOP2); |
130 |
// output_low(STOP2); |