well several cups of coffee later I have something that works.. to a fashion. The only thing with the code at the moment is that it seems to randomly revert back to the default pattern 1, so something is causing SWcount to loose / reset. I'm assuming that the audio filter is causing interfearance, even though the PIN on the PIC is tied low via a 10K resistor.
Anyway, here is the main section of the code:
Code:
;************* main program ****************
counts = 0
Main:
Pot PORTA.1,scale,D ;used to read value from 10k pot
if sw1=0 then swcount=swcount+1 ;check to see if up button pressed, if so add 1 to SWcount
if sw2=0 then goto music ;check to see if down button pressed and if so go to music
pause 60 ;debounce delay
If swcount>7 then swcount=1 ;error trap for exceeding max patterns
gosub sel1 ;go to subroutine to select pattern
FOR counts = 1 TO steps ;advance to through the entries
gosub sel2 ;go to subroutine to advance through sequence
PAUSE D ;pause period set by varible D
NEXT counts ;advance through loop to next position
goto main: ;go back to the main program and run again
music:
Pot PORTA.1,scale,D ;used to read value from 10k pot
if sw1=0 then swcount=swcount+1 ;cycles through the patterns by adding 1 to SWcount
if sw2=0 then goto main ;check to see if down button pressed and if so go to main
pause 60 ;debounce delay
If swcount>7 then swcount=1 ;error trap for exceeding max patterns
gosub sel1
If mus = 1 then counts = counts + 1 ;if bass or beat present move to the next step in pattern
gosub sel2 ;go to subroutine to display pattern in current step
PAUSE D ;pause period set by varible D
If counts = steps then counts = 0 ;if counts then reset counts to 1
goto music: ;go back to the main program and run again
;************* Subroutines *****************
Sel1:
if swcount = 1 then read Patt1, steps
if swcount = 2 then read Patt2, steps
If swcount = 3 then read Patt3, steps
if swcount = 4 then read Patt4, steps
if swcount = 5 then read Patt5, steps
If swcount = 6 then read Patt6, steps
If swcount = 7 then Read patt7, steps
return
Sel2:
if swcount = 1 then READ (Patt1+counts), PORTB
if swcount = 2 then READ (Patt2+counts), PORTB
if swcount = 3 then READ (Patt3+counts), PORTB
if swcount = 4 then READ (Patt4+counts), PORTB
if swcount = 5 then READ (Patt5+counts), PORTB
if swcount = 6 then READ (Patt6+counts), PORTB
if swcount = 7 then READ (Patt7+counts), PORTB
RETURN
Bookmarks