Subversion Repositories svnkaklik

Rev

Blame | Last modification | View Log | Download

//#device ICD=TRUE

#include ".\menic.h"

//#use fast_io(B)

#define PIEZO PIN_A6
#define LED   PIN_A7
#define MENIC  PIN_B3
#define REFPWR PIN_B1
#define MOTOR  PIN_B2

unsigned int32 n;

void pip()
{
   int1 beep;
   int i;

   for(i=0; i<250; i++)
   {
      output_bit(PIEZO, beep);
      beep=~beep;
      output_bit(LED, beep);
      delay_us(100);
   };
   output_high(PIEZO);
   output_high(LED);
}

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   setup_oscillator(OSC_4MHZ|OSC_INTRC);

//   SET_TRIS_B( 0b11110011);

   output_low(MENIC);
   output_low(MOTOR);
   output_low(REFPWR);

   pip();

   for(n=0;n<370000;n++)
//   for(n=0;n<100000;n++)
   {
//      set_timer0(0);
 //     while ( get_timer0() < 250 )
      {
         output_high(MENIC);
         delay_us(5);
         output_low(MENIC);
         delay_us(4);
//         delay_us(90);
      };
   }

   pip();

   output_high(MOTOR);
   delay_ms(3000);
   output_low(MOTOR);

   while(true)
   {
      output_high(LED);
      delay_ms(300);
      output_low(LED);
      delay_ms(300);
   }
}