195 |
helcl |
1 |
#include "C:\RS\kaki\try\mainer.h" |
|
|
2 |
|
|
|
3 |
#define PIP1 output_high(PIN_C4) |
|
|
4 |
#define PIP2 output_low(PIN_C5) |
|
|
5 |
|
|
|
6 |
void main() |
|
|
7 |
{ |
|
|
8 |
|
|
|
9 |
unsigned int8 poc; |
|
|
10 |
int8 delay; |
|
|
11 |
int16 cas; |
|
|
12 |
|
|
|
13 |
setup_adc_ports(AN0); |
|
|
14 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
15 |
setup_psp(PSP_DISABLED); |
|
|
16 |
setup_spi(SPI_SS_DISABLED); |
|
|
17 |
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1); |
|
|
18 |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); |
|
|
19 |
setup_timer_2(T2_DIV_BY_1,255,1); |
|
|
20 |
setup_ccp1(CCP_PWM); |
|
|
21 |
setup_ccp2(CCP_PWM); |
|
|
22 |
set_pwm1_duty(0); |
|
|
23 |
set_pwm2_duty(0); |
|
|
24 |
setup_comparator(NC_NC_NC_NC); |
|
|
25 |
setup_vref(FALSE); |
|
|
26 |
|
|
|
27 |
set_timer0(0); |
|
|
28 |
|
|
|
29 |
while(TRUE) |
|
|
30 |
{ |
|
|
31 |
delay=read_adc(); |
|
|
32 |
set_pwm1_duty(delay); |
|
|
33 |
set_pwm2_duty(delay); |
|
|
34 |
|
|
|
35 |
cas++; |
|
|
36 |
|
|
|
37 |
// b=cas/20; |
|
|
38 |
// b++; |
|
|
39 |
|
|
|
40 |
poc=get_timer0(); |
|
|
41 |
if (poc!=poc) |
|
|
42 |
{ |
|
|
43 |
poc++; |
|
|
44 |
PIP1; |
|
|
45 |
PIP2; |
|
|
46 |
delay_ms(10); |
|
|
47 |
!PIP1; |
|
|
48 |
!PIP2; |
|
|
49 |
delay_ms(10); |
|
|
50 |
|
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
if(cas>=65535) |
|
|
54 |
{ |
|
|
55 |
|
|
|
56 |
printf("\n\r"); |
|
|
57 |
printf("Hello world!\n\r"); |
|
|
58 |
|
|
|
59 |
printf("%u",poc+1); |
|
|
60 |
//set_timer0(0); |
|
|
61 |
} |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
} |
|
|
65 |
|
|
|
66 |
} |
|
|
67 |
|