creatorlars Posted May 4, 2009 Report Share Posted May 4, 2009 I have two questions related to the Midibox CV DOUT gate/trigger-related code available here:http://www.midibox.org/dokuwiki/doku.php?id=how_to_use_midibox_cv_with_a_dout1) Right now the code responds only to a single midi channel. How could I change it to respond to ALL midi channels?2) Instructions are given to conform the DOUT gates to 1ms triggers to use with drum modules (which is my purpose.) However, some of my modules respond to gates, not triggers (the CGS Cynare's Sustain input.) How could I modify this code to exclude specific DOUT pins from the 1ms-reset?Thanks for any help. :) I am trying to learn ASM, but the syntax is very foreign to me. Looking forward to C-based programming with the new core!!Lars Quote Link to comment Share on other sites More sharing options...
TK. Posted May 4, 2009 Report Share Posted May 4, 2009 1) Right now the code responds only to a single midi channel. How could I change it to respond to ALL midi channels?Following lines: movlw 0x90 ; check for Note On at channel #1 cpfseq MIOS_PARAMETER1, ACCESS rgoto USER_MPROC_NRE_NoNoteChn1[/code] have to be replaced by: [code] movf MIOS_PARAMETER1, W ; get status byte andlw 0xf0 ; mask out MIDI channel xorlw 0x90 ; check for Note On bnz USER_MPROC_NRE_NoNoteChn1 ; skip if not a Note On event (ignore wrong label name) 2) Instructions are given to conform the DOUT gates to 1ms triggers to use with drum modules (which is my purpose.) However, some of my modules respond to gates, not triggers (the CGS Cynare's Sustain input.) How could I modify this code to exclude specific DOUT pins from the 1ms-reset? Replace: USER_SR_Service_Finish clrf MIOS_PARAMETER1 movlw 0x00 call MIOS_DOUT_SRSet movlw 0x01 call MIOS_DOUT_SRSet movlw 0x02 call MIOS_DOUT_SRSet movlw 0x03 call MIOS_DOUT_SRSet [/code] by: [code]USER_SR_Service_Finish movlw 0x00 call MIOS_DOUT_SRGet movlw 0x00 ; (*1) andwf MIOS_PARAMETER1, F movlw 0x00 call MIOS_DOUT_SRSet movlw 0x01 call MIOS_DOUT_SRGet movlw 0x00 ; (*2) andwf MIOS_PARAMETER1, F movlw 0x01 call MIOS_DOUT_SRSet movlw 0x02 call MIOS_DOUT_SRGet movlw 0x00 ; (*3) andwf MIOS_PARAMETER1, F movlw 0x02 call MIOS_DOUT_SRSet movlw 0x03 call MIOS_DOUT_SRGet movlw 0x00 ; (*4) andwf MIOS_PARAMETER1, F movlw 0x03 call MIOS_DOUT_SRSet movlw 0x04 call MIOS_DOUT_SRGet movlw 0x00 ; (*5) andwf MIOS_PARAMETER1, F movlw 0x04 call MIOS_DOUT_SRSet(*1) .. (*5): instead of 0x00, you have to set an AND mask which matches with your requirements.E.g., if the rightmost DOUT of the second SR shouldn't be cleared after 1 mS, use "movlw 0x01" instead of "movlw 0x00"if two rightmost DOUT of the second SR shouldn't be cleared after 1 mS, use "movlw 0x03" instead of "movlw 0x00"if only the leftmost DOUT of the second SR shouldn't be cleared after 1 mS, use "movlw 0x80" instead of "movlw 0x00"etc.Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 4, 2009 Author Report Share Posted May 4, 2009 Wonderful, thank you!!!I'd like (just for ease-of-setup purposes) to be able to have a table that will assign specific MIDI notes to specific DOUT pins, in case I want to change things up after I get everything wired up. (This is a custom Midibox CV application for a modular drum machine with over 30 drum voices.) But I will save that for when I can learn a bit more of the syntax, since it seems fairly straightforward. :) Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 4, 2009 Author Report Share Posted May 4, 2009 I'm experiencing a problem with the trigger outs --Is there anything about this code (on the Wiki page) that might send only the first 8 notes to all DOUTs?For example, my problem is that Note C-1 is triggering SR1 Pin 1 and SR2 Pin 1, Note C#1 is triggering SR2 Pin 2 and SR2 Pin 2, etc.I've checked my DOUT wiring and serial ins/outs between the pins of the 595s and everything is connected correctly. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 5, 2009 Report Share Posted May 5, 2009 Yeh... movf MIOS_PARAMETER2, W ; pin number: note number - 0x24, we start with C-2 addlw -0x24 Maybe you could do with some checking in there, to deal with what should happen when the note received, is lower than C2... Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 5, 2009 Author Report Share Posted May 5, 2009 hmm, i will check into that.just a dumb newbie check -- is there anything I need to define in the code to let MIOS know how many shift registers are in the DOUT chain? Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 5, 2009 Author Report Share Posted May 5, 2009 Okay, for my own edification I've attempted to thoroughly comment each step of the code. I referred to the 18F452 datasheet to try to deduce the different instructions syntax. I also renamed some of the functions and now the DOUT pin number = MIDI note number. Can you guys let me know if I'm on the right track here? I had to guess in a couple places (couldn't find skpz in the datasheet.) I also commented out the call to CV_MIDI because my current application uses DOUT only. (I'd eventually like to modify this to translate velocity information to AOUT for specific drum triggers.) This code compiles without errors.USER_MPROC_NotifyReceivedEvent ;; BEGIN --- control DOUT pins via Note events at all channels movf MIOS_PARAMETER1, W ;; get MIDI event type & channel number andlw 0xf0 ;; ignore non-valid MIDI events & channels xorlw 0x80 ;; check for Note Off bnz USER_MPROC_NRE_NotNoteOff ;; skip if not a Note Off event USER_MPROC_NRE_NoteOff ;; if the event is Note Off bsf MIOS_PARAMETER1, 4 ;; midi event type changed to Note On clrf MIOS_PARAMETER3 ;; set velocity = 0 USER_MPROC_NRE_NotNoteOff movf MIOS_PARAMETER1, W ;; get MIDI event type & channel number andlw 0xf0 ;; ignore non-valid MIDI events & channels xorlw 0x90 ;; check for Note On bnz USER_MPROC_NRE_NotNote ;; skip if not a Note On event USER_MPROC_NRE_IsNote movf MIOS_PARAMETER3, W ;; get MIDI velocity information skpz ;; skip next instruction if velocity = 0 movlw 0x01 ;; set W = 1 movwf MIOS_PARAMETER1 ;; set MIOS_PARAMETER1 = W movf MIOS_PARAMETER2, W ;; get MIDI note value andlw 0x7f ;; ignore non-valid note values call MIOS_DOUT_PinSet ;; pin = note number, value = MIOS_PARAMETER1 USER_MPROC_NRE_NotNote ;; END --- control DOUT pins via Note events at all channels ;; process MIDI event ;; call CV_MIDI_NotifyReceivedEvent ;; for best latency: branch to USER_Tick so that the new CV values ;; will be mapped immediately rgoto USER_Tick Quote Link to comment Share on other sites More sharing options...
lylehaze Posted May 5, 2009 Report Share Posted May 5, 2009 Greetings..I regret that I don't have time to thoroughly answer your questions..But I can toss you a quick answer..Somewhere in the mios source tree is a file called macros.hOn this machine the end of the path is MIOS\mios_base_v1_0b\include\asm\macros.h(OK, so I probably have an old version..)This file defines a variety of useful macros, including skpz#define skpz btfss STATUS,ZIt's worth reading the file to see what else has been done for you.Have Fun,LyleHaze Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 5, 2009 Author Report Share Posted May 5, 2009 Thanks very much for the info, I'll check that out.I tested the above code and it works, except I'm still having the same problem with the DOUTs as described above. I am guessing I'm missing something somewhere, where I need to tell MIOS how many shift registers are connected... or maybe there's still something I overlooked with the shift register connections. I tried new 595s and that didn't help. I'll do some more double-checking tonight. Any help is appreciated! Quote Link to comment Share on other sites More sharing options...
creatorlars Posted May 6, 2009 Author Report Share Posted May 6, 2009 Resolved!The following code in main.inc had to be changed to reflect the number of shift registers connected: ;; initialize the SRIO driver movlw 0x01 call MIOS_SRIO_NumberSet This worked for me: ;; initialize the SRIO driver movlw 0x0F call MIOS_SRIO_NumberSetI'll update the wiki. Thanks for all the help! 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.