158 |
jicha |
1 |
#include "C:\RS\Schmitt\main.h" |
|
|
2 |
#define mic input(PIN_A3) |
|
|
3 |
#define LED_ON output_low(PIN_A0) |
|
|
4 |
#define LED_OFF output_high(PIN_A0) |
|
|
5 |
|
|
|
6 |
void main() |
|
|
7 |
{ |
|
|
8 |
setup_adc_ports(NO_ANALOGS); |
|
|
9 |
setup_adc(ADC_OFF); |
|
|
10 |
setup_spi(SPI_SS_DISABLED); |
|
|
11 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
12 |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); |
|
|
13 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
14 |
setup_comparator(NC_NC_NC_NC); |
|
|
15 |
setup_vref(FALSE); |
|
|
16 |
|
|
|
17 |
while(TRUE) |
|
|
18 |
{ |
|
|
19 |
while(mic); |
|
|
20 |
while(!mic); |
|
|
21 |
while(mic) |
|
|
22 |
{ |
|
|
23 |
set_timer1(0); |
|
|
24 |
LED_ON; |
|
|
25 |
while(mic); |
|
|
26 |
} |
|
|
27 |
while(!mic) |
|
|
28 |
{ |
|
|
29 |
LED_OFF; |
|
|
30 |
while(!mic); |
|
|
31 |
} |
|
|
32 |
printf("Perioda %5Lu us.\n\r",get_timer1()); |
|
|
33 |
} |
|
|
34 |
} |