Subversion Repositories svnkaklik

Rev

Rev 148 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 148 Rev 149
Line 1... Line 1...
1
#include ".\camerus.h"
1
#include ".\camerus.h"
2
 
2
 
3
#use fast_io (C)
3
#USE FAST_IO (C)
4
 
4
 
5
#define LED PIN_C0
5
#define LED    PIN_C0
6
#define HREF PIN_C5
6
#define HREF   PIN_C5
7
#define PIX PIN_C6
7
#define PIX    PIN_C6
-
 
8
#define SERVO  PIN_B7
8
 
9
 
9
void main()
10
void main()
10
{
11
{
11
   int8 cas;
12
   int8 cas;
12
 
13
 
13
   setup_adc_ports(ALL_ANALOG);
14
   setup_adc_ports(ALL_ANALOG);
14
   setup_adc(ADC_CLOCK_INTERNAL);
15
   setup_adc(ADC_CLOCK_INTERNAL);
15
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
16
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
16
   setup_timer_1(T1_DISABLED);
17
   setup_timer_1(T1_DISABLED);
17
   setup_timer_2(T2_DIV_BY_16,62,1);
18
   setup_timer_2(T2_DIV_BY_16,255,1);
18
   setup_ccp1(CCP_PWM); // RC1
19
   setup_ccp1(CCP_PWM); // RC1
19
   setup_ccp2(CCP_PWM); // RC2
20
   setup_ccp2(CCP_PWM); // RC2
20
   setup_comparator(NC_NC_NC_NC);
21
   setup_comparator(NC_NC_NC_NC);
21
   setup_vref(FALSE);
22
   setup_vref(FALSE);
22
 
23
 
23
   set_tris_c(0x11111000);
24
   set_tris_c(0b11111000);
24
 
25
 
25
   output_high(LED);
26
   output_high(LED);
26
 
27
 
27
   i2c_start();      // Reset
28
   i2c_start();      // Reset
28
   i2c_write(0xC0);
29
   i2c_write(0xC0);
Line 77... Line 78...
77
 
78
 
78
   while(true)
79
   while(true)
79
   {
80
   {
80
      while(!input(HREF));
81
      while(!input(HREF));
81
      set_timer0(0);
82
      set_timer0(0);
82
      while(input(PIX));
83
      while(input(HREF))
-
 
84
      {
-
 
85
        if(!input(PIX))
-
 
86
        {
83
      set_pwm1_duty(get_timer0());
87
          cas=get_timer0();
-
 
88
          break;
-
 
89
        }
-
 
90
      };
-
 
91
      output_high(SERVO);
84
      delay_ms(1);
92
      delay_us(1000);
-
 
93
      delay_us(cas);
-
 
94
      delay_us(cas);
-
 
95
      delay_us(cas);
-
 
96
      output_LOW(SERVO);     
-
 
97
      set_pwm1_duty(cas);
-
 
98
      set_pwm2_duty(255-cas);
85
   };
99
   };
86
}
100
}