;==========================================================================
        Title  "Bike Advance"
;   http://www.perso.wanadoo.fr/transmic/
;       23 Mai 04      Version 4.40 R0C1 for 16f84     Thierry.P
;      16f84 Horloge externe 4MHz
;      cablage compatible cdi PCM5.3
;      Copyright © Thierry PERCIN
; -------------------------------------------------------------------------
; Adaptation of the program Ign.txt "Auto Advance" from A. Nixon
; Title  "Auto Advance" for 16c54
;       24 08 94      Version 1.0      A. Nixon
;==========================================================================

        ;
        ; Ign advance starts at 1100 engine RPM
        ;
        ; Ign full advance is at 9000 engine RPM
        ;
        ; dwell time is fixed at 2mS, =  20 X 100uS loops
        ;
        ; After 1100 RPM, the ignition advance is calculated in 131 steps.
        ; This continues up until 9000 RPM is reached.
        ; 
        ;
        ; At a engine speed of 1200 RPM;
        ;
        ;        1200 / 60 = 20 revs per second
        ;          1 / 20 = 50mS per rev
        ;           1 rev = 360 degrees
        ;
        ;        36 degrees at 1200 RPM = (36 / 360) X 50 = 5mS
        ;
        ; Therefore maximum retard at 1200 RPM = 5mS after the firing
        ; point is reached. This figure remains constant down to 0 RPM.
        ;
        ; At a engine speed of 9000 RPM, maximum advance will have been reached,
        ; and ignition is immediately after the firing point is reached.
        ;
        ; The intermediate values will be looked up in an advance table map
        ; and will correspond to engine speed from 1100 RPM to 9000 RPM.
        ;
        ; As the engine RPM increases above 1100, the retard value becomes
        ; progressively lower until 9000 RPM is reached, whereby the
        ; retard value will be 0.
        ; Under 1100 RPM the retard value is fixed at 5ms (maxret)
        ;
        ;
        ; Map holds retard values in 100uS loops for every loop change
        ; in rpm rate.
        ;
        ;
        ;
;==========================================================================
;
;       PIC 16F84 wiring
;
;==========================================================================

	;                  
	;  LEDrpmLimit  <------- RA2   1+--O--+18  RA1
	;  ReverseOutput<------- RA3   2|     |17  RA0
	;                        RA4   3|     |16  Osc ------ 4MHz
	;  +5V--+----R---------> MCLR  4|     |15  Osc ------ Quartz
	;  Ground--------------- Vss   5|     |14  Vcc ------ +5Vdc
	;                        RB0   6|     |13  RB7 <------curve selector
	;                        RB1   7|     |12  RB6 ------>pickupLED
	;  Thyristor    <------- RB2   8|     |11  RB5
	;                        RB3   9+-----+10  RB4 <------pickup36°

;==========================================================================
;
;       Versions
;
;==========================================================================

        ; Version 2.3: add a reverse output to coil, detect rotor __-__
        ; Version 2.6: modif calculation, detect rotor --_--
        ; Version 2.8: modif register
        ; Version 3.0: correction at low RPM, or big retard.
        ; Version 3.1: debounce=1ms, initial delay=18ms, detect rotor high __-__
        ; Version 3.2: suppression extra pluses at low RPM
        ; Version 4.0: simplification, 4MHz cristal.trigger on decreasing edge
        ; Version 4.1: trigger on rising edge
        ; Version 4.2: map move at the end of the soft. max adv=0ms
        ; Version 4.30: 2 maps selectables
        ; Version 4.40: A different PCB
        ; scr disable code by axir4r@supernerd.com.au
        ;
        ;

;==========================================================================
;
;       Directives
;
;==========================================================================
; Page 0: 0-FF, Page1: 100-1FF, Page2: 200-2FF, Page3: 300-3ff

	ERRORLEVEL -302		; suppress message because of bank select in setup ports

        list p=16f84a    	; processor type
        ;
        __config  B'11111111110010'
        ; No code protect, PWRT on, no watchdog, Quartz 4to20Mhz
        ;
        ; Page 0: 0-FF page1: 100-1FF page2: 200-2FF page3: 300-3FF
;==========================================================================
;
;       Register Definitions
;
;==========================================================================

W                            EQU     H'0000'
F                            EQU     H'0001'

;----- Register Files------------------------------------------------------

INDF                         EQU     H'0000'
TMR0                         EQU     H'0001'
PCL                          EQU     H'0002'
STATUS                       EQU     H'0003'
FSR                          EQU     H'0004'
PORTA                        EQU     H'0005'
PORTB                        EQU     H'0006'
EEDATA                       EQU     H'0008'
EEADR                        EQU     H'0009'
PCLATH                       EQU     H'000A'
INTCON                       EQU     H'000B'

OPTION_REG                   EQU     H'0081'
TRISA                        EQU     H'0085'
TRISB                        EQU     H'0086'
EECON1                       EQU     H'0088'
EECON2                       EQU     H'0089'

;----- STATUS Bits --------------------------------------------------------

IRP                          EQU     H'0007'
RP1                          EQU     H'0006'
RP0                          EQU     H'0005'
NOT_TO                       EQU     H'0004'
NOT_PD                       EQU     H'0003'
Z                            EQU     H'0002'
DC                           EQU     H'0001'
C                            EQU     H'0000'

;----- INTCON Bits --------------------------------------------------------

GIE                          EQU     H'0007'
EEIE                         EQU     H'0006'
T0IE                         EQU     H'0005'
INTE                         EQU     H'0004'
RBIE                         EQU     H'0003'
T0IF                         EQU     H'0002'
INTF                         EQU     H'0001'
RBIF                         EQU     H'0000'

;----- OPTION Bits --------------------------------------------------------

NOT_RBPU                     EQU     H'0007'
INTEDG                       EQU     H'0006'
T0CS                         EQU     H'0005'
T0SE                         EQU     H'0004'
PSA                          EQU     H'0003'
PS2                          EQU     H'0002'
PS1                          EQU     H'0001'
PS0                          EQU     H'0000'

;==========================================================================
;
;       Define
;
;==========================================================================

#DEFINE table	PORTB,7     	; [pin13]= map selecting
#DEFINE rotor	PORTB,4     	; [pin10]= sensor input
#DEFINE coil	PORTB,2   	; [pin8]= output to coil
#DEFINE revcoil	PORTA,3		; [pin2]= reverse output to coil
#DEFINE rpmmax	PORTA,2    	; [pin1]= Min and Max RPM led
#DEFINE led	PORTB,6       	; [pin12]= pickup led

;==========================================================================
;
;       RAM Definition
;
;==========================================================================

rpmhi	equ 0Ch    	; RPM counter register high
rpmlo	equ 0Dh    	; RPM counter register low
dwell	equ 0Eh   	; dwell time counter
rtdset	equ 0Fh  	; retard value holding register
math	equ 11h   	; calculation register
coilflg	equ 12h    	; coil status
spkflg	equ 13h  	; flag after one spark
rotflg	equ 14h  	; rotor sense flag
retard	equ 15h  	; new retard value
scrflg  equ 16h         ; scr flag

;==========================================================================
;
;       Main Program
;
;==========================================================================


	org 0			; start adress 0
start   bsf    STATUS,RP0  	; go to bank 1
        movlw  H'00'       	; set all portA..
        movwf  TRISA		; ..as outputs
        movlw  B'10010000'      ; bit 0,1,2,3,5,6 = o/p's, 4,7 = i/p's
        movwf  TRISB		; set portB
	;        			
        movlw b'11000001'	; no pull-up,rising edge int,internal timer,1:4
        movwf OPTION_REG
        bcf  STATUS,RP0    	; come back into bank 0
        ;
        clrw               	; clear all variables
        clrf PORTA         	; clear variables
        clrf PORTB
        clrf math
        clrf rpmlo
        clrf coilflg

        movlw 0xff         	; rpmhi = FF initially
        movwf rpmhi
        movwf spkflg		; no spark until pickup is high
        movwf rotflg		; and no spark loop if pickup stay up
        movwf scrflg            ; no scr triggering until engine running

	movlw 0x64
	movwf retard		; retard value = 10ms initially
	;
        ;
        ;       100uS loop time
        ;       4MHz clock / 4 = 1MHz instruction cycle
        ;       cycle time = 1/1MHz  =  1uS
        ;       100uS/1uS  =  100 cycles
        ;       prescaler set to divide by 4
        ;       preset TMR0 = 231, when = 0  =  100uS
        ;       231 to 255 = 25 x 4(prescaler) = 100
        ;
        movlw .231	;movlw .206 for a 8MHz clock
        movwf TMR0
        ;
        ;
mnloop  movf TMR0,W
        btfss STATUS,Z		; is TMR0=0 ?
        goto mnloop     	; no, main delay loop
        ;
        movlw .231		; yes, re-preset TMR0 (240max)
        movwf TMR0
        ;
	incf rpmlo,F    	; increment rpmlo
        btfsc STATUS,Z  	; is rpmlo = 0 ?
        incf rpmhi,F    	; yes, increment rpmhi
        ;
	;       if rpm count > 1400h, 5120 x 100us=0.5 Sec, then it is assumed that the
        ;       motor has stopped. Reinitialize system.
        movlw 0x14
        subwf rpmhi,W
        btfsc STATUS,Z     	; rpmhi - 14 = 0 ?
        goto start         	; yes
        ;
        
rotchk  btfss rotor		; + is rotor high or low?
	;btfsc rotor		; (- detect pickup low)
        goto rnowlw             ; low
        ;
        movf rotflg,W   	; high, is it flagged high also? rotflg=FF?
        btfss STATUS,Z
        goto coilck     	; yes
        ;
        movlw 0xff 		; no
        movwf rotflg     	; flag rotor as up
        
	clrf spkflg	      	; reset flag for one spark
        goto rpmcalc		; calculate RPM
	;
	
rnowlw  movf rotflg,W   	; is it flagged low already ? rotflg=0?
        btfsc STATUS,Z
        goto coilck 	    	; yes, wasn't flagged high
        ;
        
dolow   
        clrf rotflg     	; flag rotor as down
        goto mnloop
        ;

decret	decf retard,F		; no, decrement retard then wait
	goto mnloop
	;
	                
coilck  movf coilflg,W	   	; is coil flagged high? coilflg=FF?
        btfss STATUS,Z
        goto upcoil             ; yes, then decrement dwell count
        movf retard,W		; is retard = 0 ?
        btfss STATUS,Z
        goto decret		; no, then decrement retard
        ;
	movf spkflg,W	   	; yes, a spark have been done? spkflg=FF?
        btfss STATUS,Z
        goto mnloop             ; yes, no more spark
        ;


        movf scrflg,w           ; is scrflg high? scrflg=FF?
        btfss STATUS,Z		; if scrflg=0 then skip goto skipscr
        goto skipscr            ; yes, skip scr trigger

        bsf coil		; no, go on for the first spark
        bcf revcoil

skipscr

        movlw 0xff      	; set flag for high coil
        movwf coilflg
        movwf spkflg		; set flag for one spark

        ;   ****************** YOU CAN MODIFY THE DWELL VALUE BELLOW ********
        movlw .20		; 20 X 100uS  = 2mS
        movwf dwell		; set dwell time
        ;
        goto mnloop
	;
	
upcoil  ;       		if dwell # 0 then dwell - 1
        ;			if dwell now = 0, turn on coil
        ; 
        decfsz dwell,F  	; dwell = dwell - 1
        goto mnloop     	; dwell <> 0, wait
        bcf coil		; dwell = 0, turn coil off
        bsf revcoil	  	; dwell = 0, turn revcoil on
        clrf coilflg	      	; set flag for low coil
        goto mnloop
        ;

rpmcalc ;       engine RPM <= 1100 at maximum retard, = 55ms
	;	
        ;       55mS = 550 X 100us loops, = 226Ch
        ;       ( 1000RPM for a 1cyl - 4stroke with one spark loose )
        ;       ( 1000RPM for a 1cyl - 2stroke )
        ;       (  500RPM for a 4cyl - 4stroke = 16Hz )
        ;
        ;	engine RPM >= 9000 at maximum advance, = 6.7mS
        ;       6.7mS = 67 X 100uS loops, = 43h
        ;       ( 8000RPM for a 1cyl - 4stroke with one spark loose )
        ;       ( 8000RPM for a 1cyl - 2stroke )
        ;       (  4000RPM for a 4cyl - 4stroke = 133Hz )
        ;
        ;       this routine determines whether the engine RPM
        ;       value is below 43 loop counts - max advance, or above
        ;       550 loop counts - max retard, or some where in between.
        ;       
        ;       
        ; high RPM:     	; > 9000RPM
        ;
        movf rpmhi,W
        btfss STATUS,Z  	; is rpmhi = 0?
        goto bigfv      	; no
        ;
        movf rpmlo,W
        xorlw 0x43	      	; yes, is rpmlo = 43h ?
        btfsc STATUS,Z
        goto maxadv     	; yes, do max advance
        ;
        movlw 0x43
        subwf rpmlo,W   	; no, is rpmlo < 43h ?
        btfss STATUS,C
        goto maxadv     	; yes, do max advance
        ;
        ; medium RPM:
        goto caladv     	; no, calculate new advance
        ;
        ;
        ; low RPM:      	; < 1100RPM
bigfv   movf rpmhi,W
        xorlw .2        	; is rpmhi = 2 ?
        btfsc STATUS,Z
        goto resfv      	; yes, see if rpmlo = 26h
        ;
        movlw .2
        subwf rpmhi,W   	; no, is high byte > 2 ?
        btfsc STATUS,C
        goto maxret     	; yes, do max retard
        ;

        movlw 0x00         	; allow pic to control scr
        movwf scrflg

        goto caladv     	; no, calculate new advance

        ;
resfv   movf rpmlo,W
        xorlw 0x26      	; rpmhi = 2, does rpmlo = 26h ?
        btfsc STATUS,Z
        goto maxret     	; yes, do max retard
        ;
        movlw 0x26
        subwf rpmlo,W   	; no, is rpmlo > 26h ?
        btfsc STATUS,C
        goto maxret     	; yes, do max retard
        ;
        ;
        ; the formula to get the data stored in the map is as follows
        ;
        ;                 rpmhi/lo count  -  74
        ;    131   -    ---------------------------
        ;                           4
        ;
caladv  movlw d'74'    		; rpmhi/lo - 74
        subwf rpmlo,F		; rpmlo = rpmlo - 74
        btfss STATUS,C
        decf rpmhi,F
        ;
        ; divide result by 4
        ;
        bcf STATUS,C
        rrf rpmhi,F
        rrf rpmlo,F     	; / 2
        ;
        bcf STATUS,C
        rrf rpmhi,F
        rrf rpmlo,F     	; / 4
        ;
        movlw .131      	; 131 entries in map list
        movwf math
        ;
        movf rpmlo,W
        subwf math,W    	; W = 131 - result
        ;
        bcf PCLATH,0		; default map is at h'200'
        bsf PCLATH,1
	btfss table		; is table select low?
        bsf PCLATH,0		; yes,then select table N°2 at h'300'
        ;
        call map		; read map
        movwf rtdset    	; come back with new retard value
        ;bcf rpmmax	 	; turn debug led off
        ;
rpmset  clrf rpmhi		; clear RPM counters
        clrf rpmlo
	movf rtdset,W		; transfert advance value
        movwf retard
        goto mnloop		; (therefore minimum retard is 1 loop-100us)
        ;
maxret  movlw 30h		; < 1100RPM
        movwf rtdset     	; retard value = 30h (~4.8ms)   16hz
        ;bcf rpmmax 		; turn off maxrpm led
        goto rpmset
        ;
maxadv  clrf rtdset      	; > 9000RPM retard value = 0ms	124hz
        ;bsf rpmmax	 	; turn on maxrpm led
        goto rpmset
        ;
map     org h'200'		; store map1 at 200h
	addwf PCL,1		; add W + PCL

	;  *********** INSERT YOUR OWN VALUES HERE *******************


        retlw 1Eh     ;3ms    
        retlw 1Eh     ;3ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 17h     ;2.3ms    
        retlw 17h     ;2.3ms    
        retlw 17h     ;2.3ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 11h     ;1.7ms    
        retlw 11h     ;1.7ms    
        retlw 11h     ;1.7ms    
        retlw 10h     ;1.6ms    
        retlw 10h     ;1.6ms    
        retlw 10h     ;1.6ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Ah     ;1ms    
        retlw 0Ah     ;1ms    
        retlw 0Ah     ;1ms    
        retlw 9h     ;1ms   2525rpm 
        retlw 9h     ;0.9ms   2562rpm 
        retlw 8h     ;0.9ms   2600rpm 
        retlw 8h     ;0.9ms   2639rpm 
        retlw 8h     ;0.8ms   2679rpm 
        retlw 7h     ;0.8ms   2721rpm 
        retlw 7h     ;0.7ms   2764rpm 
        retlw 6h     ;0.7ms   2808rpm 
        retlw 6h     ;0.6ms   2854rpm 
        retlw 6h     ;0.6ms   2902rpm 
        retlw 5h     ;0.6ms   2952rpm 
        retlw 5h     ;0.5ms   3003rpm 
        retlw 4h     ;0.5ms   3057rpm 
        retlw 4h     ;0.4ms   3112rpm 
        retlw 4h     ;0.4ms   3170rpm 
        retlw 3h     ;0.4ms   3230rpm 
        retlw 3h     ;0.3ms   3292rpm 
        retlw 3h     ;0.3ms   3357rpm 
        retlw 2h     ;0.3ms   3425rpm 
        retlw 2h     ;0.2ms   3496rpm 
        retlw 2h     ;0.2ms   3570rpm 
        retlw 1h     ;0.2ms   3648rpm 
        retlw 1h     ;0.2ms   3729rpm 
        retlw 1h     ;0.1ms   3814rpm 
        retlw 1h     ;0.1ms   3903rpm 
        retlw 1h     ;0.1ms   3997rpm 
        retlw 1h     ;0.1ms   4096rpm 
        retlw 0h     ;0ms   4200rpm 
        retlw 0h     ;0ms   4309rpm 
        retlw 0h     ;0ms   4425rpm 
        retlw 0h     ;0ms   4547rpm 
        retlw 0h     ;0ms   4677rpm 
        retlw 0h     ;0ms   4815rpm 
        retlw 0h     ;0ms   4961rpm 
        retlw 0h     ;0ms   5118rpm 
        retlw 0h     ;0ms   5284rpm 
        retlw 0h     ;0ms   5463rpm 
        retlw 0h     ;0ms   5654rpm 
        retlw 0h     ;0ms   5860rpm 
        retlw 0h     ;0ms   6082rpm 
        retlw 0h     ;0ms   6322rpm 
        retlw 0h     ;0ms   6582rpm 
        retlw 0h     ;0ms   6866rpm 
        retlw 0h     ;0ms   7176rpm 
        retlw 0h     ;0ms   7517rpm 
        retlw 0h     ;0ms   7892rpm 
        retlw 0h     ;0ms   9000rpm 


        ;  ********* END OF YOUR OWN VALUES ******************

        retlw 1Eh     ; in case of overlap

        ; line565
        ;
        
map2    org h'300'		; store second map at 300h
	addwf PCL,1		; add W + PCL

	;  *********** INSERT YOUR OTHERS VALUES HERE ***************

        retlw 1Eh     ;3ms    
        retlw 1Eh     ;3ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Dh     ;2.9ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Ch     ;2.8ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Bh     ;2.7ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 1Ah     ;2.6ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 19h     ;2.5ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 18h     ;2.4ms    
        retlw 17h     ;2.3ms    
        retlw 17h     ;2.3ms    
        retlw 17h     ;2.3ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 16h     ;2.2ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 15h     ;2.1ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 14h     ;2ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 13h     ;1.9ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 12h     ;1.8ms    
        retlw 11h     ;1.7ms    
        retlw 11h     ;1.7ms    
        retlw 11h     ;1.7ms    
        retlw 10h     ;1.6ms    
        retlw 10h     ;1.6ms    
        retlw 10h     ;1.6ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Fh     ;1.5ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Eh     ;1.4ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Dh     ;1.3ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Ch     ;1.2ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Bh     ;1.1ms    
        retlw 0Ah     ;1ms    
        retlw 0Ah     ;1ms    
        retlw 0Ah     ;1ms    
        retlw 9h     ;1ms   2525rpm 
        retlw 9h     ;0.9ms   2562rpm 
        retlw 8h     ;0.9ms   2600rpm 
        retlw 8h     ;0.9ms   2639rpm 
        retlw 8h     ;0.8ms   2679rpm 
        retlw 7h     ;0.8ms   2721rpm 
        retlw 7h     ;0.7ms   2764rpm 
        retlw 6h     ;0.7ms   2808rpm 
        retlw 6h     ;0.6ms   2854rpm 
        retlw 6h     ;0.6ms   2902rpm 
        retlw 5h     ;0.6ms   2952rpm 
        retlw 5h     ;0.5ms   3003rpm 
        retlw 4h     ;0.5ms   3057rpm 
        retlw 4h     ;0.4ms   3112rpm 
        retlw 4h     ;0.4ms   3170rpm 
        retlw 3h     ;0.4ms   3230rpm 
        retlw 3h     ;0.3ms   3292rpm 
        retlw 2h     ;0.3ms   3357rpm 
        retlw 2h     ;0.2ms   3425rpm 
        retlw 2h     ;0.2ms   3496rpm 
        retlw 1h     ;0.2ms   3570rpm 
        retlw 1h     ;0.1ms   3648rpm 
        retlw 1h     ;0.1ms   3729rpm 
        retlw 0h     ;0ms   3814rpm 
        retlw 0h     ;0ms   3903rpm 
        retlw 0h     ;0ms   3997rpm 
        retlw 0h     ;0ms   4096rpm 
        retlw 0h     ;0ms   4200rpm 
        retlw 0h     ;0ms   4309rpm 
        retlw 0h     ;0ms   4425rpm 
        retlw 0h     ;0ms   4547rpm 
        retlw 0h     ;0ms   4677rpm 
        retlw 0h     ;0ms   4815rpm 
        retlw 0h     ;0ms   4961rpm 
        retlw 0h     ;0ms   5118rpm 
        retlw 0h     ;0ms   5284rpm 
        retlw 0h     ;0ms   5463rpm 
        retlw 0h     ;0ms   5654rpm 
        retlw 0h     ;0ms   5860rpm 
        retlw 0h     ;0ms   6082rpm 
        retlw 0h     ;0ms   6322rpm 
        retlw 0h     ;0ms   6582rpm 
        retlw 0h     ;0ms   6866rpm 
        retlw 0h     ;0ms   7176rpm 
        retlw 0h     ;0ms   7517rpm 
        retlw 0h     ;0ms   7892rpm 
        retlw 0h     ;0ms   9000rpm 


        ;  ********* END OF YOUR OWN VALUES ******************
        retlw 1Eh     ; in case of overlap

        ; line704
        ;
        ;       reset vector
        ;
        ;
        org 3FFh		; if the software get lost,
        ;
        ;
        ;
        goto start		; It goes back home.
        ;
        ;
        ;
        end
