Jump to content

Small sequencer asm problem


yoho
 Share

Recommended Posts

Hi there,

I have been inspired by the idea of MBSeq in a small box with not too much controls, 1 LCD and 8 encoders and some buttons and started working on a prototype. Due to parts I had, I started on a V2 seq, I had a "452" lying around :-)

To implement a shift function this what I have done:

in app_defines.h change


	;; free: 0x16b

to this:

SEQ_BUTTON_SHIFT_STATE EQU 0x16b	;; free: 0x16b

In seq_core.inc add this after the line with SEQ_MODE1_RECORD..

SEQ_BUTTON_NOSHIFT         EQU 0   ; Shift buttons

SEQ_BUTTON_SHIFT        EQU 1 ;

Ofcourse I added something like this to the setup*.asm (according to your own box)

	DIN_ENTRY   SEQ_BUTTON_Shift,    3,  7

in seq_buttons.inc I added this after the SEQ_BUTTON_All function

;; --------------------------------------------------------------------------

;;  Enable to shift

;; --------------------------------------------------------------------------

SEQ_BUTTON_Shift


	SET_BSR	SEQ_BASE


#if DEFAULT_BEHAVIOUR_BUTTON_SHIFT

	;; Toggle Mode (default):

	;; exit if button depressed

	btfsc	MIOS_PARAMETER2, 0

	return

	;; else toggle status

	btg	    SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED

#else

	;; On/Off Mode:

	;; button status controls mode directly

	bcf	    SEQ_BUTTON_SHIFT_STATE, SEQ_MODE_SHIFT, BANKED

	btfss	MIOS_PARAMETER2, 0

	bsf	    SEQ_BUTTON_SHIFT_STATE, SEQ_MODE_NOSHIFT, BANKED

#endif


	return

In seq_gp.inc in function SEQ_GP_function I added this (some lines repeated for the right line)

SEQ_GP_Button

	;; request display update

	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ


	;; the menu select function overlays everything

	SET_BSR	SEQ_BASE

	BRA_IFSET SEQ_MODE0, SEQ_MODE0_MENU, BANKED, SEQ_GP_Mode4_Button



    ;; This is new: setting the gp no according to shift state: add 8 = setting bit 3

    BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, SEQ_GP_NoShift

    bsf MIOS_PARAMETER1, 3

SEQ_GP_NoShift

up till now this is working ;-) well almost. The shift key does the job on GP buttons but, you can only see it working after pushing one... Pointers anyone? From here things get worse. I tried to "copy" this to the encoder function, but it is going wrong. I know that you have to add 8 to WREG but I didn't succeed in getting that working. The bit setting trick didn't work. So any help is appreciated

SEQ_ENC_Handler

	;; save encoder number in SEQ_CURRENT_STEP and SEQ_EVNTS

	SET_BSR SEQ_BASE



    ;;new:  Altered for shift function


    BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, SEQ_Enc_NoShift


    ;could be this

    ;bsf MIOS_PARAMETER1, 3

    ;or this?

    addwf 8, 0, BANKED

    movf	MIOS_PARAMETER1, W

SEQ_Enc_NoShift

This last piece of programming drama (being a pro: this brings me back to my programming kindergarten years) triggers all of them, but: all encoders are shifted one position: first enc does second value....last encoder does first value. And subtracting one from W just crashed the app. Can anyone shine a beautiful light?

Cheers....

Edited by yoho
Link to comment
Share on other sites

I managed to find the solution myself: this code should be placed in seq_enc.inc


SEQ_ENC_Handler


	;; save encoder number in SEQ_CURRENT_STEP and SEQ_EVNTS

	SET_BSR SEQ_BASE


    ;; Altered for shift function

    BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, SEQ_Enc_NoShift

    ;bsf MIOS_PARAMETER1, 3


    ;Erik Add 8 to the encoder number... well 7 but it works ?!?

    movlw 7

    addwf MIOS_PARAMETER1, 0


SEQ_Enc_NoShift

I'm off to the next challenges: doing a one-button track change. Up till now it looks like (in seq_buttons.inc) this but isn't working :-)

;; --------------------------------------------------------------------------

;;  Select Track 1/2/3/4

;; --------------------------------------------------------------------------


;; Erik: Different for single button here! 

;;SEQ_BUTTON_Track

	SET_BSR	SEQ_BASE


        movwf	SEQ_SELECTED_TRKS,BANKED

        rlncf    W, 1, 0

	andwf   0xf

	rgoto SEQ_BUTTON_Trackx_Cont


SEQ_BUTTON_Track1

Edited by yoho
Link to comment
Share on other sites

  • 2 months later...

After being offline for half a century:

Getting one of the leds to show the shift status in this case the beat-led.

In seq_leds.inc just after


SEQ_LED_UpdateIRQ_NoBeat

	movlw	DEFAULT_BEAT_INDICATOR_LED

	call	MIOS_DOUT_PinSet

insert this

#if DEFAULT_SHIFT_ENABLED

;; Erik : update shift led

	SET_BSR	SEQ_BASE

	clrf	MIOS_PARAMETER1

	BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, SEQ_LED_UpdateIRQ_NoShift

SEQ_LED_UpdateIRQ_Shift

	setf	MIOS_PARAMETER1

SEQ_LED_UpdateIRQ_NoShift

	movlw	DEFAULT_SHIFT_INDICATOR_LED

	call	MIOS_DOUT_PinSet

#endif

	;; ---[ increment the LED row counter (used when DEFAULT_TRACK_LEDS_ENABLED set ]---


In setup_mbseq_v2.asm add this

#define DEFAULT_SHIFT_INDICATOR_LED 0x07;

And the shift led should work... To have the gp leds working with the shift go to seq_leds.inc again and edit

SEQ_LED_UpdateIRQ_GPLED

	;; transfer current LED pattern to IRQ_TMP[12]

	movff	SEQ_GP_LED0, IRQ_TMP1

	movff	SEQ_GP_LED1, IRQ_TMP2

to look like this

SEQ_LED_UpdateIRQ_GPLED

	;; transfer current LED pattern to IRQ_TMP[12]


#if DEFAULT_SHIFT_ENABLED

	BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, SEQ_LED_UpdateIRQ_GPNoShift

	movff	SEQ_GP_LED1, IRQ_TMP1

	bra     SEQ_LED_UpdateIRQ_GPEndShift


SEQ_LED_UpdateIRQ_GPNoShift

	movff	SEQ_GP_LED0, IRQ_TMP1

SEQ_LED_UpdateIRQ_GPEndShift


#else

	movff	SEQ_GP_LED0, IRQ_TMP1

	movff	SEQ_GP_LED1, IRQ_TMP2

#endif

I skipped the one-button-track-change for now. I thought it is better to focus on the display changing steps with the shift status. Here's the challenge in seq_buttons.inc, first part we've seen before, how do I get this to work?

;; --------------------------------------------------------------------------

;;  Enable to shift

;; --------------------------------------------------------------------------

SEQ_BUTTON_Shift

	SET_BSR	SEQ_BASE


#if DEFAULT_BEHAVIOUR_BUTTON_SHIFT

	;; Toggle Mode (default):

	;; exit if button depressed

	btfsc	MIOS_PARAMETER2, 0

	return

	;; else toggle status

	btg	    SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED

#else

	;; On/Off Mode:

	;; button status controls mode directly

	bcf	    SEQ_BUTTON_SHIFT_STATE, SEQ_MODE_SHIFT, BANKED

	btfss	MIOS_PARAMETER2, 0

	bsf	    SEQ_BUTTON_SHIFT_STATE, SEQ_MODE_NOSHIFT, BANKED

#endif



;;Does this work???

    BRA_IFCLR SEQ_BUTTON_SHIFT_STATE, SEQ_BUTTON_SHIFT, BANKED, seq_set_no_shift


    bsf	    SEQ_EVNTS, 2, BANKED

    rgoto seq_set_shift_update


seq_set_no_shift

	bcf	    SEQ_EVNTS, 2, BANKED


seq_set_shift_update

    ;; request display update

bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ


	return

Edited by yoho
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...