135 |
jicha |
1 |
#include "C:\RS\Ladicka2\main.h" |
|
|
2 |
#define vstup C1OUT |
|
|
3 |
#define krok 1 |
|
|
4 |
|
|
|
5 |
void main() |
|
|
6 |
{ |
|
|
7 |
int16 n; //promena poctu ubehlych cyklu |
|
|
8 |
|
|
|
9 |
setup_adc_ports(NO_ANALOGS); |
|
|
10 |
setup_adc(ADC_OFF); |
|
|
11 |
setup_psp(PSP_DISABLED); |
|
|
12 |
setup_spi(SPI_SS_DISABLED); |
|
|
13 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
14 |
setup_timer_1(T1_DISABLED); |
|
|
15 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
16 |
setup_comparator(A0_VR_A1_VR); |
|
|
17 |
setup_vref(VREF_LOW|0); //komparator porovnava s 0 V |
|
|
18 |
|
|
|
19 |
while(TRUE) |
|
|
20 |
{ |
|
|
21 |
n=0; //vynuluje namereny cas |
|
|
22 |
while(vstup) //pro vystup komparatoru 1 |
|
|
23 |
{ |
|
|
24 |
n++; //kazdy cyklus pricte 1,meri dobu kdy vyst.komp. 1 |
|
|
25 |
delay_ms(krok); //pocka urcenou dobu cyklu |
|
|
26 |
} |
|
|
27 |
while(!vstup) //meri dobu kdy vyst.komp. 0 |
|
|
28 |
{ |
|
|
29 |
n++; |
|
|
30 |
delay_ms(krok); |
|
|
31 |
} |
|
|
32 |
printf("%Lu ms\n\r",n); //posle namereny cas pres Rs232 |
|
|
33 |
}//meri dobu mezi dveme pruchody vstupniho signalu A0 nulou smerem dolu(nabeznymi hranami C1OUT) |
|
|
34 |
} |