;******************************************************************
;Copyright (c) (28.03.2007) by Visionics India
;All Rights Reserved
;STEPPERMOTOR CONTROLLER:
;This program is meant to provide clock wise full step sequence
;Rev 1.0 - Date :28.03.2007
;Written by: vipl
;Changes:
;******************************************************************

#include <p16c5x.inc>  ;This header file is included for all PIC projects.
	
;***** VARIABLE DEFINITIONS

temp_var        udata
DVAR2           res    1	      ;DVAR2 varible declaration
DVAR            res    1	      ;DVAR variable declaration


;**********************************************************************
reset_vector    code   0x1ff         ;processor reset vector
		goto   start

MAIN            CODE   0x000
start

                movlw  0x00          ;move literal value to accumulator
                tris   PORTB         ;Set PORT B as output
loop
                movlw  0x01          ;move literal value to accumulator
                movwf  PORTB         ;move accumulator to portB
                  
                call   Delay         ;call Delay subroutine
                   
                movlw  0x02          ;move literal value to accumulator
                movwf  PORTB         ;move accumulator to portB
                  
                call   Delay         ;call Delay subroutine
                  
                movlw  0x04          ;move literal value to accumulator
                movwf  PORTB         ;move accumulator to portB
                 
                call   Delay         ;call Delay subroutine
                  
                movlw  0x08          ;move literal value to accumulator
                movwf  PORTB         ;move accumulator to portB
                 
                call   Delay         ;call Delay subroutine

                goto   loop
                  

Delay

   		movlw  0x02	     ;move literal value to accumulator
   		movwf  DVAR2         ;move 02 to outer maximum loop count
DelayOuter
		movlw  0x02	     ;move literal value to accumulator
  		movwf  DVAR          ;move 02 to inner maximum loop count
DelayInner
   		decfsz DVAR,1        ;decrement DVAR  if result is not zero execute
				     ;next step otherwise skip next step
  		goto   DelayInner

  		decfsz DVAR2,1	     ;decrement DVAR2  if result is not zero execute
				     ;next step otherwise skip next step
   		goto   DelayOuter

		RETLW  0

                end                   ;directive end of program'


