Rev Author Line No. Line
176 jicha 1 #include "C:\RS\Meric_casu\main.h"
2 #define mic input(PIN_A4)
3 #define POCET 10
4 #define E1 3034
5  
6 void main()
7 {
8 int16 perioda;
9 int8 i;
10 int32 cas;
11 signed int16 vysl;
12  
13 setup_adc_ports(NO_ANALOGS);
14 setup_adc(ADC_OFF);
15 setup_spi(SPI_SS_DISABLED);
16 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
17 setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
18 setup_timer_2(T2_DISABLED,0,1);
19 setup_comparator(NC_NC_NC_NC);
20 setup_vref(FALSE);
21 output_B(0xFF);
22  
23 while(TRUE)
24 {
25 cas=0;
26 for(i=0;i<POCET;i++)
27 {
28 while(mic);
29 while(!mic);
30 while(mic)
31 {
32 set_timer1(0);
33 //LED_ON;
34 //delay_us(1400);
35 while(mic);
36 }
37 while(!mic)
38 {
39 //LED_OFF;
40 //delay_us(1400);
41 while(!mic);
42 }
43 perioda=get_timer1();
44 //printf("Perioda %5Lu us.\n\r",perioda);
45 cas+=perioda;
46 }
47 cas/=i;
48 printf("Perioda %5Lu us.\n\r",cas);
49 vysl=cas-E1;
50 if(vysl<-53)output_B(0b10111111);
51 if((vysl>-53)&&(vysl<-35))output_B(0b11011111);
52 if((vysl>-35)&&(vysl<-17))output_B(0b11101111);
53 if((vysl>-17)&&(vysl<17))output_B(0b11110111);
54 if((vysl>17)&&(vysl<35))output_B(0b11111011);
55 if((vysl>35)&&(vysl<52))output_B(0b11111101);
56 if(vysl>52)output_B(0b11111110);
57 }
58 }