Jump to content

force value 0 or 127 AIN


Recommended Posts

Hi

I'm trying to porting a MIOS application wrote in C to ASM. All work just done but i need an help on this:

In my hardware I'm using a 2 position switch on an AIN unmuxed and it is working good with C allowing it to assume only value 0 or 127.

I'm not able to translate in ASM.

My C code ( in pot section ) is:

				

                {

			// Only allow value 0 or 127

			this_value = this_value < 63 ? 0 : 127;


			// If valid, send CC out

			MIOS_MIDI_TxBufferPut(0xb0);

			MIOS_MIDI_TxBufferPut(53);

			MIOS_MIDI_TxBufferPut(this_value);

		}

Any help to make the same thing in ASM under the section USER_AIN_NotifyChange?

In this moment I'm using the mios_table.inc for specify the midimessages of the pots.

thank you very much.

Dexter

Link to comment
Share on other sites

Hi,

considered that bit #6 will be set on values >= 64, you could write:



movlw 0xb0
call MIOS_MIDI_TxBufferPut
movlw 0x53
call MIOS_MIDI_TxBufferPut
movlw 127
btfss this_value, 6 ; bit 6 is set on values >= 64
movlw 0
call MIOS_MIDI_TxBufferPut
[/code]

Btw.: you split the range between 0..62 and 63..127, but it's better to split it at 64, since it's exactly the half of the value range.

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi Tk and thank you for your suggestion.

Is not possible for me to compile with the code you gave me because MPLAB return to me with this error:

MAIN.ASM 289 : Symbol not previously defined (this_value)

something like the "this_value" not recognize...

This is the entire code ( related to pot section)



USER_AIN_NotifyChange


        JUMPTABLE_2BYTES 2        ; (2 entries because in this trying we use only 2 unmuxed AIN)

        rgoto        Function_for_WREG_00 ; AIN 0

        rgoto        Function_for_WREG_01 ; AIN 1

    rgoto AIN_END        

    rgoto AIN_END       

    rgoto AIN_END;

    rgoto AIN_END;

    rgoto AIN_END

    rgoto AIN_END

;;;;;;;;;;;;**************************************

;

;;;;;;;;;;;;**************************************

Function_for_WREG_00		; 0-127_AIN 0


    movlw   0xb0

    call    MIOS_MIDI_TxBufferPut

    movlw   0x53

    call    MIOS_MIDI_TxBufferPut

    movlw   127

    btfss   this_value, 6   ; bit 6 is set on values >= 64

    movlw   0

    call    MIOS_MIDI_TxBufferPut


Function_for_WREG_01		; 0-127_AIN 1


    movlw   0xb0

    call    MIOS_MIDI_TxBufferPut

    movlw   0x54

    call    MIOS_MIDI_TxBufferPut

    movlw   127

    btfss   this_value, 6   ; bit 6 is set on values >= 64

    movlw   0

    call    MIOS_MIDI_TxBufferPut



AIN_END


I can't understand where's the error...

Thank you very much!

Bye

Dexter

Link to comment
Share on other sites

MAIN.ASM 289 : Symbol not previously defined (this_value)

something like the "this_value" not recognize...

I can't understand where's the error...

The assembler tells you exactly what the problem is: It doesn't know what "this_value" is supposed to be, as it's not defined anywhere (in the C code it must be defined somewhere). Instead of "this_value" you have to use the address(es) where the AIN values are stored.

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...