Please help support the site by donating at the link below.https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8ZRU34U47BESW
;******MAIN LOOP***************Start btfsc GPIO, PROGSTATE goto Start ;wait for the fun to begin call Wait10ms btfsc GPIO, PROGSTATE ;button is down for 10ms goto StartRelease btfss GPIO, PROGSTATE ;wait for button release goto Release call Wait10ms btfss GPIO, PROGSTATE ;wait for button release goto Release
movlw 0x40 addwf STATER, f ;cyclic change in state manipulates ;last 2 bits in STATER.
btfsc STATER, 7 ;state 1 or 2 goto Continue01 btfsc STATER, 6 goto State2
movlw FIRERATE1 ;state 1, off movwf FREQR bcf FLAGS, LEDON ;turn off LED goto StartState2 movlw FIRERATE1 ;state 2, 42ms cycle movwf FREQR bsf FLAGS, LEDON ;turn on LED goto StartContinue01 btfsc STATER, 6 goto State4 movlw FIRERATE2 ;state 3, 30 ms cycle movwf FREQR bcf FLAGS, LEDON ;turn off LED goto StartState4 movlw FIRERATE3 ;state 4, 22ms cycle movwf FREQR bsf FLAGS, LEDON ;turn on LED goto Start
Or you could get rid of the main loop and cycle through modes with the brute force method that most usually do.
Another thing you could do is change the main routine to start in the first mode (off for most) and then call the button test as a routine. If the button is not pressed, keep looping until it is pressed. Once it is pressed, move the new value of FREQR and wait for another button test looping until the button is pressed. Keep doing this for however modes you want.
movlw FIRERATE1 ;state 2 movwf FREQR bcf FLAGS, COD5MODE bsf FLAGS, LEDON ;turn on LED bcf FLAGS, BURSTACTIVE; bsf FLAGS, BURSTACTIVE ;uncomment to activate burstfire for state 2; movlw 0X04; movwf BURSTRATEStart btfss FLAGS, TRIGOUT call BursttestCG btfsc FLAGS, TRIGOUT call BursttestMX btfsc GPIO, PROGSTATE goto Start ;wait for the fun to begin call Wait10ms btfsc GPIO, PROGSTATE ;button is down for 10ms goto StartRelease btfss GPIO, PROGSTATE ;wait for button release goto Release call Wait10ms btfss GPIO, PROGSTATE ;wait for button release goto Release movlw FIRERATE2 ;state 3 movwf FREQR bcf FLAGS, COD5MODE ;uncomment to turn COD5 mode off/comment to turn COD5 mode on bsf FLAGS, COD5MODE ;uncomment to turn COD5 mode on/comment to turn COD5 mode OFF bcf FLAGS, BURSTACTIVE ;bsf FLAGS, BURSTACTIVE ;uncomment to turn burstfire on/comment to turn burstfire OFF movlw 0X04 ;burst count 0x02 = 3 shot burst/0x03 = 4 shot burst/0x04 = 5 shot burst bcf FLAGS, LEDON ;turn off LED 1/2 sec movlw 0x0A movwf TEMP3