Rev Author Line No. Line
253 kaklik 1 #include "main.h"
2  
3  
4 void main()
5 {
6 int16 ble;
7  
8 setup_adc_ports(AN0);
9 setup_adc(ADC_CLOCK_INTERNAL);
10 setup_spi(SPI_SS_DISABLED);
11 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
12 setup_timer_1(T1_DISABLED);
13 setup_timer_2(T2_DIV_BY_4,254,1);
14 setup_ccp1(CCP_PWM);
15 setup_ccp2(CCP_PWM);
16 set_pwm1_duty(1023);
17 set_pwm2_duty(1023);
18 setup_comparator(NC_NC_NC_NC);
19 setup_vref(FALSE);
20  
21 port_b_pullups (TRUE);
22  
23 set_adc_channel(0);
24 delay_us(20);
25  
26 while(TRUE)
27 {
28 while(!input(PIN_B7));
29 ble=read_adc();
30 set_pwm1_duty(ble);
31 set_pwm2_duty(1023-ble);
32 printf("* %lu *\n\r", ble);
33 delay_ms(200);
34 set_pwm2_duty(ble);
35 set_pwm1_duty(1023-ble);
36 delay_ms(200);
37 }
38 }