Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2 kaklik 1
//#device ICD=TRUE
2
 
3
#include ".\menic.h"
4
 
5
//#use fast_io(B)
6
 
7
#define PIEZO PIN_A6
8
#define LED   PIN_A7
9
#define MENIC  PIN_B3
10
#define REFPWR PIN_B1
11
#define MOTOR  PIN_B2
12
 
13
unsigned int32 n;
14
 
15
void pip()
16
{
17
   int1 beep;
18
   int i;
19
 
20
   for(i=0; i<250; i++)
21
   {
22
      output_bit(PIEZO, beep);
23
      beep=~beep;
24
      output_bit(LED, beep);
25
      delay_us(100);
26
   };
27
   output_high(PIEZO);
28
   output_high(LED);
29
}
30
 
31
void main()
32
{
33
 
34
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
35
   setup_adc(ADC_OFF);
36
   setup_spi(FALSE);
37
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
38
   setup_timer_1(T1_DISABLED);
39
   setup_timer_2(T2_DISABLED,0,1);
40
   setup_comparator(NC_NC_NC_NC);
41
   setup_vref(FALSE);
42
 
43
   setup_oscillator(OSC_4MHZ|OSC_INTRC);
44
 
45
//   SET_TRIS_B( 0b11110011);
46
 
47
   output_low(MENIC);
48
   output_low(MOTOR);
49
   output_low(REFPWR);
50
 
51
   pip();
52
 
53
   for(n=0;n<370000;n++)
54
//   for(n=0;n<100000;n++)
55
   {
56
//      set_timer0(0);
57
 //     while ( get_timer0() < 250 )
58
      {
59
         output_high(MENIC);
60
         delay_us(5);
61
         output_low(MENIC);
62
         delay_us(4);
63
//         delay_us(90);
64
      };
65
   }
66
 
67
   pip();
68
 
69
   output_high(MOTOR);
70
   delay_ms(3000);
71
   output_low(MOTOR);
72
 
73
   while(true)
74
   {
75
      output_high(LED);
76
      delay_ms(300);
77
      output_low(LED);
78
      delay_ms(300);
79
   }
80
}