;******************************************************************************
;Software License Agreement                                         
;                                                                    
;The software supplied herewith by Microchip Technology             
;Incorporated (the "Company") is intended and supplied to you, the  
;Company’s customer, for use solely and exclusively on Microchip    
;products. The software is owned by the Company and/or its supplier,
;and is protected under applicable copyright laws. All rights are   
;reserved. Any use in violation of the foregoing restrictions may   
;subject the user to criminal sanctions under applicable laws, as   
;well as to civil liability for the breach of the terms and         
;conditions of this license.                                        
;                                                                    
;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,  
;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED  
;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A       
;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,  
;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR         
;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.       
; *******************************************************************
; PICkit 2 Lesson 1 - "Hello World"
;
; This turns on LED 0 on the 44-Pin Demo Board.
;
; *******************************************************************
; *    See 44-pin Demo Board User's Guide for Lesson Information    *
; *******************************************************************
#include <p16F887.inc>
	__CONFIG    _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
	__CONFIG    _CONFIG2, _WRT_OFF & _BOR21V

cblock 0x20
	csordul					;
	novel
	temp
	temp2
endc
     org 0
Start:
	banksel		TRISD		;
	clrf		TRISD		;
	bsf       STATUS,RP0     ; Bank 1
     movlw     b'00000111'    ; configure Timer0.  Sourced from the Processor clock;
     movwf     OPTION_REG     ; Maximum Prescaler
	movlw		0x02
	movwf		novel
	bcf			STATUS,RP0
	bcf			STATUS,RP1
	movlw		0x01
	movwf		novel
	movwf		temp
Main:
	btfss     INTCON,T0IF    ; wait here until Timer0 rolls over
     goto      Main
    bcf       INTCON,T0IF    ; flag must be cleared in software
;	incf		temp
;	btfss		temp,7
;	goto		$-2
;	incf		temp2
;	btfss		temp2,7
;	goto		Main
	call		motor
	movwf		PORTD		;
	goto		Main		;
motor:
	incf	novel,0
	movwf	novel
	movwf	csordul
	movlw	0x03
	addwf	csordul,1
	movlw	0x01
	btfsc	csordul,3
	movwf	novel
	movf	novel,0
	addwf	PCL,0
    movwf   PCL
kimenet:	
	retlw	b'10000001'
	retlw	b'10000001'
	retlw	b'10000010'
	retlw	b'10000010'
     end
     
