#include "C:\RS\gmc\main.h"
//#define PIP1 output_high(PIN_A2)
//#define PIP2 output_low(PIN_A3)

void main()
{

unsigned int8 poc;
//int8 delay;
int cas;
int b;

b=0;


   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DIV_BY_1,1023,1);
   setup_ccp1(CCP_PWM);
   setup_ccp2(CCP_PWM);
   set_pwm1_duty(265);
   set_pwm2_duty(265);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

     

   
   while(TRUE)
   {
   //set_timer0(0); 
   for(b=0;b<5;b++)
  
   {
      //delay=read_adc();        //pwm-ka je nastavena na pevnou hodnotu
     // set_pwm1_duty(delay);
      //set_pwm2_duty(delay); 
      
      
     poc=get_timer0();
   if (poc!=poc)
    {
      poc++;
      
      cas=get_timer1();
      cas++;
    /*output_low(PIN_A2);
    output_high(PIN_A3); 
     delay_us(500);              
    output_high(PIN_A2);
    output_low(PIN_A3);*/
     if(cas=~cas)
    {
    output_low(PIN_C4);
    output_high(PIN_C5); 
     delay_ms(300);              
    output_high(PIN_C4);
    output_low(PIN_C5);
   }
      //!PIP1;
      //!PIP2;
     //delay_cycles(300);
     //PIP1;
     //PIP2;
     //delay_ms(110);
    }
    
   

      delay_ms(500);
   }
             
               
  printf("\n\r");
  printf("sum of peaks per 1s:\n\r");
  printf("%u",poc);
  set_timer0(0);  
  
  
    }    


}