Rev Author Line No. Line
211 helcl 1 #include "C:\RS\gmc\main.h"
2 //#define PIP1 output_high(PIN_A2)
3 //#define PIP2 output_low(PIN_A3)
4  
5 void main()
6 {
7  
8 unsigned int8 poc;
9 //int8 delay;
10 int cas;
11 int b;
12  
13 b=0;
14  
15  
16 setup_adc_ports(NO_ANALOGS);
17 setup_adc(ADC_OFF);
18 setup_psp(PSP_DISABLED);
19 setup_spi(SPI_SS_DISABLED);
20 setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
21 setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8);
22 setup_timer_2(T2_DIV_BY_1,1023,1);
23 setup_ccp1(CCP_PWM);
24 setup_ccp2(CCP_PWM);
25 set_pwm1_duty(265);
26 set_pwm2_duty(265);
27 setup_comparator(NC_NC_NC_NC);
28 setup_vref(FALSE);
29  
30  
31  
32  
33 while(TRUE)
34 {
35 //set_timer0(0);
36 for(b=0;b<5;b++)
37  
38 {
39 //delay=read_adc(); //pwm-ka je nastavena na pevnou hodnotu
40 // set_pwm1_duty(delay);
41 //set_pwm2_duty(delay);
42  
43  
44 poc=get_timer0();
45 if (poc!=poc)
46 {
47 poc++;
48  
49 cas=get_timer1();
50 cas++;
51 /*output_low(PIN_A2);
52 output_high(PIN_A3);
53 delay_us(500);
54 output_high(PIN_A2);
55 output_low(PIN_A3);*/
56 if(cas=~cas)
57 {
58 output_low(PIN_C4);
59 output_high(PIN_C5);
60 delay_ms(300);
61 output_high(PIN_C4);
62 output_low(PIN_C5);
63 }
64 //!PIP1;
65 //!PIP2;
66 //delay_cycles(300);
67 //PIP1;
68 //PIP2;
69 //delay_ms(110);
70 }
71  
72  
73  
74 delay_ms(500);
75 }
76  
77  
78 printf("\n\r");
79 printf("sum of peaks per 1s:\n\r");
80 printf("%u",poc);
81 set_timer0(0);
82  
83  
84 }
85  
86  
87 }