	#include <p16F684.inc>	; processor specific variable definitions
	#include bipolar.inc	; include variable definitions and defines
	__CONFIG   _CP_OFF & _CPD_OFF & _BOD_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _FCMEN_OFF & _IESO_OFF 

Initialize:
	OSCCON,4 =1;		// Internal oscillator frequeny = 8 MHz
	TRISA = 0b00001111;
	TRISC = 0b00000011;
	WPUA = 0; 				Disable weak pullups
	ADCON1 = 0b00100000;	//ADC Fosc/32
	ANSEL = 4;				// analog pin: AN2
	PR2	= 0x3F;				//TMR2 period = 0xFF
	IOCA = 8;				//Interrupt on pin change enabled for pin RA3


	CMCON0 = 4;				//; Turn on comparators
	ADCON0 = 0b00001001;	//; AN2 selected, A/D module turned on
	T2CON = 0b01111100;		//TMR2 on; 1:1 prescaler; 1:16 postscaler
	INTCON	= 8;			//; RAIE interrupt

	Mode =0;				//; Start in Mode 1
ModeSelect:
	State,0 = 0;			//; initialize motor state
	Index =0;				// initialize duty cycle lookup index
	Delay	=1;				//; initialize delay
/*
	movlw	high ModeSelectTable  ; jump to the current mode
	movwf	PCLATH
	movf	Mode,w
	andlw	0x07
	addlw	low ModeSelectTable
	btfsc	STATUS,C	
	incf	PCLATH,f
	movwf	PCL
	
ModeSelectTable:
	goto	Mode1		; motor off
	goto	Mode2		; single-step mode
	goto	Mode3		; half-step mode
	goto	Mode4		; microstep mode
	goto	Mode5		; position control mode
	nop					
	nop		
	nop	
	clrf	Mode
	goto	Mode1		; start back at mode 1
*/
