mb944 Posted March 26, 2005 Report Share Posted March 26, 2005 Hello midiboxers!I am really getting envolved in midiboxing and having enjoyed all the physical hardware developement side of it,I'm having some fun with Coding.What I am triying to do here is to Light a red led when an encoder approaches its maximum absolute value (above 100).I am using enc_example2_v1_3Â as a skelletton for my little project.I noticed that Just before sending the encoder value (third midi byte), MIOS moves it from TMP1 to WI assumed I could insert my code here and compare W with the WARNING_LEVEL...Here's what I'm wrote: ;; send the third MIDI byte movf TMP1, W ; value from 0x00 to 0x7fmovlw 0x64 ; ABOVE THIS VALUE,LIGHT WARNING LEDmovwf WARNING_LEVELmovf TMP1, W ; value from 0x00 to 0x7fCPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVELmovlw 0x14CALL MIOS_DOUT_PinSet1; LIGHT WARNING LEDCall MIOS_MIDI_TxBufferPutAt the moment, PINSET1 is being called every time I move the encoder.Can I make CPFSGT skip two lines? Better still, can I use something like:IF w>100 thenmovlw 0x14CALL MIOS_DOUT_PinSet1end ifThanks for any suggestions!Best regards,Alex Quote Link to comment Share on other sites More sharing options...
TL Posted March 26, 2005 Report Share Posted March 26, 2005 CPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVEL goto No_Warning movlw 0x14 CALL MIOS_DOUT_PinSet1; LIGHT WARNING LED No_Warning Call MIOS_MIDI_TxBufferPut I think this works... Quote Link to comment Share on other sites More sharing options...
mb944 Posted March 26, 2005 Author Report Share Posted March 26, 2005 Thanks TL!It works fine!! best regards,Alex Quote Link to comment Share on other sites More sharing options...
stryd_one Posted March 26, 2005 Report Share Posted March 26, 2005 The 'skip' instructions only skip the next instruction, so you were only skipping "movlw  0x14" :)You could probably also do something like:CPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVELCALL USER_WARNING_LED; LIGHT WARNING LED SUBROUTINECALL MIOS_MIDI_TxBufferPutAnd have ;; --------------------------------------------------------------------------;; FUNCTION: USER_WARNING_LED;; DESCRIPTION: Lights the warning LED;; IN: -;; OUT: -;; USES: W;;;; --------------------------------------------------------------------------USER_WARNING_LED    movlw  USER_WARNING_LED0_PIN ; Set Warning LED Pin Value   CALL MIOS_DOUT_PinSet1; LIGHT WARNING LED   RETURNIncluded elsewhere. Don;t forget to define USER_WARNING_LED0_PIN somewhere too.Makes it usable in other areas of code, more modular, etc...Of course if you want more than one warning LED it may be better to pass the values of the pins prior to calling subroutine, like you did it...It's 4:30am and I am very very tired, I hope I haven't missed something here heheheh :) 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.