//*********************************************************************
//*  HI-TECH C SOURCE CODE FOR PULSE GENERATOR MODULE
//*********************************************************************
void main()
{

 TRIS = 0b00001000;	//GP3 input : all others output
 FOSC4 = 0;		//GP2 is an I/O pin
 CMCON  = 0b11110111;	//comparator off:pullups off:wakeup off
 OPTION = 0b11000101;	//prescaler assigned to TMR0 @ 1:64
	
 while(1)		//loop forever
 {
     GP2 = 1;		//GP2 = HIGH
     TMR0 = 0x80;	//load TMR0
     while(TMR0 & 0x80);//count from 0b10000000 to 0b00000000

     GP2 = 0;		//GP2 = LOW
     TMR0 = 0x80;	//load TMR0 
     while(TMR0 & 0x80);//count from 0x80 to 0x00
 }//while(1)
}//main

//*********************************************************************
//*  HI-TECH C SOURCE CODE FOR LED DIMMER MODULE
//*********************************************************************

void main()
{
 unsigned char x,y,z;

 TRIS = 0b00001000;	//GP3 input : all others output
 FOSC4 = 0;		//GP2 is an I/O pin
 CMCON  = 0b11110111;	//comparator off:pullups off:wakeup off
 OPTION = 0b11000010;	//prescaler assigned to TMR0 @ 1:8
	
 y = 0x04;		//initialize y
 z = 0x80;		//initialize z

 while(1)		//loop forever
 {
 do			//outer do loop
 {
    x=0xFF;

  do			//inner do loop
  {
     GP2 = 1;		//GP2 = HIGH
     TMR0 = y;		//load TMR0
     while(TMR0 & y);	//count for y time

     GP2 = 0;		//GP2 = LOW
     TMR0 = z;		//load TMR0 
     while(TMR0 & z);	//count for z time
   }while(--x);		//do inner loop until x is decremented to 0

    y *= 2;		//multiply y x 2
    z /= 2;		//divide z by 2
  }while(y);		//do outer loop until y = 0

  y = 0x04;		//reinitialize y
  z = 0x80;		//reinitialize z
 }//while(1)
}//main

//*********************************************************************
//*  HI-TECH C SOURCE CODE FOR VOLTAGE BOOSTER MODULE
//*********************************************************************
void main()
{

 TRIS = 0b00001000;	//GP3 input : all others output
 FOSC4 = 0;		//GP2 is an I/O pin
 CMCON  = 0b11110111;	//comparator off:pullups off:wakeup off
 OPTION = 0b11000000;	//prescaler assigned to TMR0 @ 1:2
	
 while(1)		//loop forever
 {
  GP2 = 1;		//GP2 = HIGH
  TMR0 = 0x04;		//load TMR0
  while(TMR0 & 0x04);	//count from 0b00000100 to 0b00001000

  GP2 = 0;		//GP2 = LOW
  TMR0 = 0x80;		//load TMR0 
  while(TMR0 & 0x80);	//count from 0x80 to 0x00
 }//while(1)
}//main
//*********************************************************************
//*  HI-TECH C SOURCE CODE FOR ONE-SHOT MODULE
//*********************************************************************
void main()
{
 unsigned int x,y;
 TRIS = 0b00001000;	//GP3 input : all others output
 FOSC4 = 0;		//GP2 is an I/O pin
 CMCON  = 0b11110111;	//comparator off:pullups off:wakeup off
 OPTION = 0b11000111;	//prescaler assigned to TMR0 @ 1:256
	
 GP2 = 0x00;		//clear GP2
 while(1)		//loop forever
 {	
  while(!GP3);		//wait for GP3 to go HIGH
  TMR0 = 0x80;		//debounce the switch closure
  while(TMR0 & 0x80);	//loop for 35mS using TMR0 with prescaler @ 1:256
  GP2 = 1;		//set GP2
  for(x=0;x<0xFFFF;++x)	//delay for one-shot time
   ++y;
  GP2 = 0;		//clear GP2
  while(GP3);		//wait for button release:GP3 to go LOW
  TMR0 = 0x80;		//debounce button release
  while(TMR0 & 0x80);	//loop for 35mS
 }
}
