jeroddumas Posted June 26, 2003 Report Share Posted June 26, 2003 Hi everyone,I just completed the electronics to my first MIOS project. ;D ;D ;D It is a controller for NI B4 organ. I used the AIN 64 DIN 128 DOUT128 program as an example for my MIOS programming. All is fine with the exection of button functioning. How do you set the button mode to toggle in MIOS. If anyone can post an example of how to change that for me I would great;y appreciate the help. Quote Link to comment Share on other sites More sharing options...
TK. Posted June 29, 2003 Report Share Posted June 29, 2003 Hi Jeroddumas,you have to store the button state in a register, it has to be inverted every time the button is pressed.Possible modification for the AIN64_DIN128_DOUT128 application (untested) - replaceUSER_DIN_NotifyToggle ;; a button has been pressed or depressed. ;; Send value which has been defined in MIOS_MPROC_EVENT_TABLE ;; save button number in TMP3 - we use it later to print out a message movff MIOS_PARAMETER1, TMP3 ;; save button value in TMP4 movff MIOS_PARAMETER2, TMP4 by: USER_DIN_NotifyToggle ;; a button has been pressed or depressed. ;; Send value which has been defined in MIOS_MPROC_EVENT_TABLE ;; don't continue if button has been depressed IFSET MIOS_PARAMETER2, 0, return ;; toggle button state btf BUTTON_STATE, 0 ;; save button number in TMP3 - we use it later to print out a message movff MIOS_PARAMETER1, TMP3 ;; save button value in TMP4 movff BUTTON_STATE, TMP4 the BUTTON_STATE variable has to be located to a free address in app_defines.h If you want to use more than one toggle button, you could store up to 8 states in this register: USER_DIN_NotifyToggle ;; a button has been pressed or depressed. ;; Send value which has been defined in MIOS_MPROC_EVENT_TABLE ;; don't continue if button has been depressed IFSET MIOS_PARAMETER2, 0, return ;; save button number in TMP3 - we use it later to print out a message movff MIOS_PARAMETER1, TMP3 ;; toggle state of button 0 to 7 movf MIOS_PARAMETER1, W ; get button number call MIOS_HLP_GetBitORMask ; get mask - here for XOR (invert) function xorwf BUTTON_STATE, F ; invert the appr. flag ;; set TMP4 (the button value) depending on flag setf TMP4 ; by default it's set (0x00 will be sent) movf MIOS_PARAMETER1, W ; get button number call MIOS_HLP_GetBitANDMask ; get AND mask andwf BUTTON_STATE, W ; mask out the appr. flag skpz ; skip if flag is zero clrf TMP4 ; else clear TMP4 (0x7f will be sent) More than 8 buttons w/ toggle function can be realized with an array. And if you want to select the toggle function, you need to add a "enable" flag. However, the upcoming migrated MIDIbox64 application will support this on a more comfotable way :)Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
jeroddumas Posted June 29, 2003 Author Report Share Posted June 29, 2003 So Thorston I would enter in app_define.hButton_state equ 0x010or any free location correct. I am really not a programmer, but I figure that I can figure out a little. Let me know if I am correct or incorrect. Thanks, and you are brilliant TK. By the way how long before MB 64 is converted to MIOS? Quote Link to comment Share on other sites More sharing options...
TK. Posted July 7, 2003 Report Share Posted July 7, 2003 yes, thats correct. But you should use capitalized letters for all constants (register names), just for consistency reasons.Migration of MB64: I'm unsure, although it wouldn't take longer than one day, it's just a low-priority task for me. It could happen in one week or in one month...Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
jeroddumas Posted July 7, 2003 Author Report Share Posted July 7, 2003 Okay Thorston two problems here, if you can help. First on the one button toggle, I cannot get the build to work MBLAB comes badck with this error:Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p18F452 "main.asm" /l"main.lst" /e"main.err"Error[122] C:\WINDOWS\DESKTOP\MY MIOS PROJECTS\COPY OF AIN64_DIN128_DOUT128_V1_1\AIN64_DIN128_DOUT128_V1_1\MAIN.ASM 230 : Illegal opcode (BUTTON_STATE)Halting build on first failure as requested.BUILD FAILEDThe second example builds fine, but the buttons don't toggle, they co to )) and stay there. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
TK. Posted July 9, 2003 Report Share Posted July 9, 2003 Maybe the syntax is wrong. You can find the error messages and the appr. files/lines in "main.err"Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
jeroddumas Posted July 9, 2003 Author Report Share Posted July 9, 2003 This is the MAIN.ERR file:Error[122] C:\WINDOWS\DESKTOP\MY MIOS PROJECTS\COPY OF AIN64_DIN128_DOUT128_V1_1\AIN64_DIN128_DOUT128_V1_1\MAIN.ASM 230 : Illegal opcode (BUTTON_STATE)If this is of any help. Thanks Quote Link to comment Share on other sites More sharing options...
TK. Posted July 9, 2003 Report Share Posted July 9, 2003 So, which code can be seen in main.asm, line 230?Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
jeroddumas Posted July 9, 2003 Author Report Share Posted July 9, 2003 this line 230 of the main.asm file, thanks for you r help thorston:btf BUTTON_STATE, 0 Quote Link to comment Share on other sites More sharing options...
TK. Posted July 14, 2003 Report Share Posted July 14, 2003 Hi Jeroddumas,you have to insert a blank (space or tab character) before the "btg" instruction, otherwise the assembler assumes that "btg" is a label and "BUTTON_STATE" the instruction.Best Regards, Thorsten. 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.