Rev Author Line No. Line
184 helcl 1 #include ".\MAINW4.h"
2  
3 #define gm PIN_A4 // tady by mely byt pulzy
4 #define pip1 PIN_C4 //cvakani
5 #define pip2 PIN_C5 //cvakani taky/opacne, aby to cvakalo vic nahlas
6 //#define pip1(false)
7 //#define pip2(true)
8 //#define pip1 output_high //vystupy inverzne
9 //#define pip2 output_low
10  
11  
12 void main()
13 {
14 int8 pocet;
15 int8 delay;
16  
17  
18 setup_adc_ports(AN0);
19 setup_adc(ADC_CLOCK_DIV_2);
20 setup_psp(PSP_DISABLED);
21 setup_spi(SPI_SS_DISABLED);
22 setup_timer_0(RTCC_DIV_1|RTCC_EXT_L_TO_H);
23 setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
24 setup_timer_2(T2_DIV_BY_1,255,1);
25 setup_ccp1(CCP_PWM);
26 setup_ccp2(CCP_PWM);
27 set_pwm1_duty(0);
28 set_pwm2_duty(0);
29 setup_comparator(NC_NC_NC_NC);
30 setup_vref(FALSE);
31  
32  
33 //set_timer0(0);
34 pocet=0;
35 while(TRUE)
36 {
37 delay=read_adc();
38 set_pwm1_duty(delay);
39 set_pwm2_duty(delay);
40  
41  
42  
43  
44 //if(get_timer0()) // jestli zmena na vystuppu trubice, tak citni
45  
46 if(input(gm))
47 {
48  
49 //pocet=(get_timer0()); // tak pocitej do promeny pocet
50 pocet++; //pricti 1
51 output_low(pip1); //vystupy inverzne do zeme a na Vdd
52 delay_ms(10);
53 output_low(pip2);
54 delay_ms(10);
55 //output_high(pip1);
56 //output_low(pip2);
57 //delay_ms(10);
58  
59 }
60 }
61  
62 //delay_ms(6000);
63 printf("%d",pocet);
64 }