Rev 2160 Rev 2161
Line 1... Line 1...
1 #include "main.h" 1 #include "main.h"
2 #include <math.h> 2 #include <math.h>
-   3  
-   4 #define INTN_PIN PIN_D7
3 #include "GP2.h" 5 #include "GP2.h"
4   6  
5 #define VERSION 0.2 7 #define VERSION 0.2
6   8  
7 #define ONE_WIRE_PIN PIN_E2 9 #define ONE_WIRE_PIN PIN_E2
Line 45... Line 47...
45 delval2=0x0; 47 delval2=0x0;
46 delval3=0x0; 48 delval3=0x0;
47 49
48 TDC_update_registers(); 50 TDC_update_registers();
49   51  
50 delay_ms(100); 52 delay_ms(10);
51   53  
52 //----------------------------------------------- Mereni 2 54 //----------------------------------------------- Measuring mode 2
53 55
54 TDC_init(); 56 TDC_init();
55 -  
56 delay_ms(50); 57 delay_ms(50);
57 -  
58 TDC_start_cycle(); 58 TDC_start_cycle();
59 -  
60 delay_ms(200); 59 While(!input(INTN_PIN)); // waiting for interrupt flag
61 60
62 //----------------------------------------------- Pocitani 61 //----------------------------------------------- Pocitani
63   62  
64 // printf("Time2: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4)); 63 // printf("Time2: %LX %LX %LX %LX ", TDC_get_measurement(1), TDC_get_measurement(2), TDC_get_measurement(3), TDC_get_measurement(4));
65   64  
66 65
67 output_low(TDC_ENABLE); //status register 66 output_low(TDC_ENABLE); //status register read
68 ret8=0; 67 ret8=0;
69 ret8=(0b1011<<4)|4; 68 ret8=(0b1011<<4)|4;
70 spi_xfer(TDC_stream,ret8,8); 69 spi_xfer(TDC_stream,ret8,8);
71 ret16=spi_xfer(TDC_stream,0,16); 70 ret16=spi_xfer(TDC_stream,0,16);
72 output_high(TDC_ENABLE); 71 output_high(TDC_ENABLE);
-   72
73 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()); 73 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()); //status register print
74   74  
75 printf("Time2: %3.7f %3.7f %3.7f \r\n", TDC_mrange2_get_time(1), TDC_mrange2_get_time(2), TDC_mrange2_get_time(3)); 75 printf("Time2: %3.7f %3.7f %3.7f \r\n", TDC_mrange2_get_time(1), TDC_mrange2_get_time(2), TDC_mrange2_get_time(3));
76   76  
77   77  
78 //----------------------------------------------- Nastaveni registru 78 //----------------------------------------------- Nastaveni registru
79 79
80 MRange=TDC_MRANGE1; 80 /* MRange=TDC_MRANGE1;
81 hit1=TDC_MRANGE1_HIT1_NOAC; 81 hit1=TDC_MRANGE1_HIT1_NOAC;
82 hit2=TDC_MRANGE1_HIT2_NOAC; 82 hit2=TDC_MRANGE1_HIT2_NOAC;
83 hitin1=TDC_HITIN1_1; 83 hitin1=TDC_HITIN1_1;
84 hitin2=TDC_HITIN2_1; 84 hitin2=TDC_HITIN2_1;
85 en_int= TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT; 85 en_int= TDC_INT_ALU | TDC_INT_ENDHIT | TDC_INT_TIMEOUT;
Line 113... Line 113...
113   113  
114 printf("Time1: %3.7f %3.7f %3.7f \r\n", TDC_mrange1_get_time(1,0,1,1), TDC_mrange1_get_time(2,0,2,1), TDC_mrange1_get_time(1,1,2,1)); 114 printf("Time1: %3.7f %3.7f %3.7f \r\n", TDC_mrange1_get_time(1,0,1,1), TDC_mrange1_get_time(2,0,2,1), TDC_mrange1_get_time(1,1,2,1));
115   115  
116 /// ----------------------------------------------- Temperature masurement 116 /// ----------------------------------------------- Temperature masurement
117   117  
118   118 */
119 TDC_reset(); 119 TDC_reset();
120 portnum=TDC_TPORTNUM_4; 120 portnum=TDC_TPORTNUM_4;
121 Tcycle=TDC_TCYCLE_SHORT; 121 Tcycle=TDC_TCYCLE_SHORT;
122 fakenum=TDC_TFAKENUM_2; 122 fakenum=TDC_TFAKENUM_2;
123 selclkT=TDC_TSELCLK_128HS; 123 selclkT=TDC_TSELCLK_128HS;