#include "C:\RS\Ladicka2\main.h"
#define vstup C1OUT
#define krok 1

void main()
{
   int16 n;
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(A0_VR_A1_VR);
   setup_vref(VREF_HIGH|0);

   while(TRUE)
   {
      n=0;
      while(vstup)
      {
         n++;
         delay_ms(krok);
      }
      while(!vstup)
      {
         n++;
         delay_ms(krok);
      }
      printf("%Lu ms\n\r",n);
   }
}