Speed_Set_rt
clrf Speed_cnt ;Clears Speed_cnt to start counting again... can be commented out to keep on counting instead of resetting.
clrf PORTA ;Clears the LEDs
btfss PORTB,0 ;waits for button press
goto $-1 ;else it loops
Speed_set_loop
call _400 ;The delays slows the program down so that the register increments are visible on LEDs
call _400 ;2500 cycles (roughly)
call _400
call _400
call _400
call _400
call _100
incf Speed_cnt,f ;increments the Speed counter
movlw d'11' ;used to stop Speed_cnt from going higher than 10
xorwf Speed_cnt,w ;XORs Speedcnt
btfsc STATUS,Z ;If it is equal to 11, reset it
clrf Speed_cnt ;Clears Speedcnt if it is 11
movfw Speed_cnt ;Writes Speed_cnt to work register
movwf PORTA ;Outputs work on PORTA
btfsc PORTB,0 ;Waits for release of button
goto Speed_set_loop ;otherwise it loops
call Bounce ;Runs delay to account for 'bounce' of tactile switch
btfsc PORTB,0 ;Tests for release again...
goto Speed_set_loop ;If still pressed, loop again
bcf INTCON,INT0IF ;Clears interrupt
sublw d'11' ;Subtracts work from 11, to invert Speed, its not working atm
movwf Speed ;Moves inverted value to speed
goto Interrupt_exit ;Exits interrupt routine