dexter2010 Posted August 25, 2010 Report Share Posted August 25, 2010 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 Quote Link to comment Share on other sites More sharing options...
TK. Posted August 25, 2010 Report Share Posted August 25, 2010 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. Quote Link to comment Share on other sites More sharing options...
dexter2010 Posted August 31, 2010 Author Report Share Posted August 31, 2010 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 Quote Link to comment Share on other sites More sharing options...
nILS Posted August 31, 2010 Report Share Posted August 31, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.