smc Posted August 23, 2011 Report Share Posted August 23, 2011 Hi Thorsten, Regarding the CV project, I'm trying to instrument the code below (found in cv_map.inc package). The semicolons are my instrumented debugging code I added (of course now shown as commented out). Principally, I used this type of instrumentation in various places in the code and it seems it works fine. However, in "CV_MAP_Hlp_ConvCurve_Cont" routine. It outputs on the MIDI some ridiculous values and actually by adding the instrumentation it causes the routine not to work at all. Basically, the aim is to read the variable CV_AOUT_L , CV_AOUT_H & output them on the midi. I'm also playing around & modifying the curve tables & to verify that the CV_AOUT_L & CV_AOUT_H are getting the correct values I expect. My question is without using the oscilloscope to measure the CV outputs. Is there another way to instrument this part of the code without affecting the routine. Thank you. CV_MAP_Hlp_ConvCurve_Cont ;movlw 0xc0 ;call MIOS_MIDI_TxBufferPut ;------>debug here clrc rlf PRODL, W addwf TBLPTRL, F movlw 0x00 addwfc TBLPTRH, F tblrd*+ movff TABLAT, CV_AOUT_L tblrd*+ movff TABLAT, CV_AOUT_H ;movf CV_AOUT_L , W ;andlw 0x7f ;call MIOS_MIDI_TxBufferPut ;----->debug here ;movf CV_AOUT_H , W ;andlw 0x7f ;call MIOS_MIDI_TxBufferPut ;----->debug here return Quote Link to comment Share on other sites More sharing options...
TK. Posted August 23, 2011 Report Share Posted August 23, 2011 In general you are doing the right thing here, this is a nice debugging help! :) But you have to consider, that MIOS_MIDI_TxBufferPut will overwrite the so called "bank selection register" (BSR) And since you are accessing variables which are in a banked range (>=0x80..<0xf80) CV_AOUT_L EQU 0x10c ; used by cv_map.inc as temporary storage CV_AOUT_H EQU 0x10d ; used by cv_map.inc as temporary storage [/code] you either have to use BANKED accesses, and restore the BSR after MIOS_MIDI_TxBufferPut call (1), or you have to use operations which don't require BANKED accesses (2) 1) [code] SET_BSR CV_BASE ; if not already done before movf CV_AOUT_L, W, BANKED andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here SET_BSR CV_BASE ; is defined in app_defines.h 2) movff CV_OUT_L, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here SET_BSR CV_BASE ; is defined in app_defines.h [/code] The second example has the advantage, that you don't need to restore the BSR when dumping multiple values, e.g.: [code] movff CV_OUT_L, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here movff CV_OUT_H, WREG andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here SET_BSR CV_BASE ; is defined in app_defines.h it has the disadvantage, that a "movff" equivalent isn't available for arithmetic instructions. Therefore finally (3) the proposed solution: ;; send a 3-byte event (CC) movlw 0xb0 call MIOS_MIDI_TxBufferPut SET_BSR CV_BASE ; if not already done before ;; send first 7 bits movf CV_AOUT_L, W, BANKED andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here SET_BSR CV_BASE ; is defined in app_defines.h ;; send next 7 bits (AOUT_LH leftshifted by 1) rlf CV_AOUT_L, W, BANKED rlf CV_AOUT_H, W, BANKED andlw 0x7f call MIOS_MIDI_TxBufferPut ;----->debug here SET_BSR CV_BASE ; is defined in app_defines.h [/code] yes, we like C! ;-) Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
smc Posted August 24, 2011 Author Report Share Posted August 24, 2011 HI Thorsten, Sorry for not coming back to you earlier... The solution you provided is just great !! I tried it yesterday evening and it worked like a charm. Though, still not 100 % sure how the MIOS_MIDI_TxBufferPut affects the BSR. Anyway, I admire your knowledge :D Vielen Dank 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.