Jump to content

Tutoriel MPLAB


djsampling

Recommended Posts

Voici un tuto pour configurer des faders motorisés et des encodeurs rotatif:

1-Télécharger et installer MPLAB de microchips et Perl.

2-Télécharger le dossier midibox64e_V2_2.zip sur ucapps

3-Décompresser midibox64e_V2_2 dans un disque local ( ex: C:/ )

NB: ne pas le décompresser dans des sous dossiers comme dans vos documents si non MPLAB va créer des erreurs

4-Ouvrir MPLAB, aller sur Project==>New

dans cette fenêtre vous indiquez un nom et dans Project Directory créer un dossier avec le même nom de votre projet toujour dans disque local ( ex: C:/ )

5-Dans la fenêtre qui est déjà ouverte(où alors View-->Projet, pour ouvrir la fenêtre) avec le nom de votre projet.mcp

Faire un clique droit sur le dossier Source Files-->Add Files

Ouvrir le dossier midibox64e_V2_2 et choisir le fichier main.

C'est ici qu'on change les CODES, voici ceux de ma configuration, 32 encodeurs, 64 boutons, 64 LED, 8 faders motorisés.

------------------------------------------------------------------------------------------

;

;

; MIOS Application

; MIDIbox64E

;

;

#ifndef SEPERATE_SETUP_FILE

; Hardware related setup:

;

; Number of connected encoders: 1-64

#define DEFAULT_NUMBER_ENCS 32 ; number of connected encoders

; NOTE: the encoders have to be assigned to the DIN pins in mios_tables.inc

;

; Width of a group - normaly matches with the number of connected encoders, but

; the MB64E_LCD_PrintGroupNumber function in mb64e_bank.inc only supports

; group widths which are a power of two (1, 2, 4, 8, 16, 32, 64)

#define DEFAULT_ENCODER_GROUP_WIDTH 32

; Number of connected buttons

; Allowed values: 1-64

#define DEFAULT_NUMBER_BUTTONS 64 ; number of connected buttons

;

; debounce counter (see the function description of MIOS_SRIO_DebounceSet)

; Use 0 for high-quality buttons, use higher values for low-quality buttons

; NOTE: with a value > 0 the ledrings will flicker on every button movement!

#define DEFAULT_SRIO_DEBOUNCE_CTR 32

;

;

; A difficult decition: define here if you want to store many banks or many patches

; in the (optional) BankStick(s).

; - Bank based (PATCHMODE 0): 8 complete configurations are stored in each BankStick

; - Patch based (PATCHMODE 1): 1 configuration bank and 128 patches are stored in each BankStick

#define DEFAULT_PATCHMODE 0

;

; Chip Select Number of BankStick which should be used:

; -1: allows the MIDIbox to address up to 8 BankSticks (-> 64/8 Banks)

; 0: the MIDIbox addresses only the BankStick with CS=0 (-> 8/1 Banks)

; ...

; 7: the MIDIbox addresses only the BankStick with CS=7 (-> 8/1 Banks)

; all others: don't use any BankStick

;

; * -1 is the most prefered choice, also when only one BankStick is connected.

; * specify a CS number 0...7 when you are using different Applications

; with your MIDIbox in order to assign a dedicated EEPROM to it.

; * specifiy any other number to disable BankStick support at all

#define DEFAULT_BANKSTICK_CS -1

;

; Channel which is used to send a program change event on bank changes

; and to listen for bank change requests

; Allowed values: 1-16

#define DEFAULT_BANK_PRG_CHNG_CHANNEL 16

;

; Channel which is used to send a program change event on patch changes

; and to listen for patch change requests

; Allowed values: 1-16

#define DEFAULT_PATCH_PRG_CHNG_CHANNEL 15

;

; here you can change the default device ID

#define DEFAULT_DEVICE_ID 0x00

;

; if this option is enabled (1), the DEFAULT_DEVICE_ID won't be used, but

; it will be automatically derived from the MIOS Device ID instead

#define DEFAULT_AUTO_DEVICE_ID 1

;

; For MIDI activity monitor: define the DOUT pins for the Rx and Tx LED

#define DEFAULT_MIDI_MONITOR_ENABLED 0 ; if 1, the Tx/Rx LEDs are enabled

#define DEFAULT_MIDI_RX_LED 0x40 ; DOUT SR#9, pin D0

#define DEFAULT_MIDI_TX_LED 0x41 ; DOUT SR#9, pin D1

;

; --> define the DOUT registers which are connected to the LED rings here:

; --> the shift registers are counted from one here - means: 1 for the first, 2 for the second, etc...

; --> please mark unused ledrings with 0

#define LEDRINGS_SR_ENC1_16_CATHODES_1 0 ; first shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC1_16_CATHODES_2 0 ; second shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC1_16_ANODES_1 0 ; first shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC1_16_ANODES_2 0 ; second shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC17_32_CATHODES_1 0 ; first shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC17_32_CATHODES_2 0 ; second shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC17_32_ANODES_1 0 ; first shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC17_32_ANODES_2 0 ; second shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC33_48_CATHODES_1 0 ; first shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC33_48_CATHODES_2 0 ; second shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC33_48_ANODES_1 0 ; first shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC33_48_ANODES_2 0 ; second shift register with anodes of the first 16 LED rings

;

#define LEDRINGS_SR_ENC49_64_CATHODES_1 0 ; first shift register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC49_64_CATHODES_2 0 ; second register with cathodes of the first 16 LED rings

#define LEDRINGS_SR_ENC49_64_ANODES_1 0 ; first shift register with anodes of the first 16 LED rings

#define LEDRINGS_SR_ENC49_64_ANODES_2 0 ; second shift register with anodes of the first 16 LED rings

;; see the documentation of MIOS_ENC_SpeedSet for the purpose of these values

#define DEFAULT_ENC_SPEED_NORMAL_MODE MIOS_ENC_SPEED_NORMAL

#define DEFAULT_ENC_SPEED_NORMAL_DIV 0

#define DEFAULT_ENC_SPEED_SLOW_MODE MIOS_ENC_SPEED_SLOW

#define DEFAULT_ENC_SPEED_SLOW_DIV 6 ; (6: increment on every 7th step)

#define DEFAULT_ENC_SPEED_FAST_MODE MIOS_ENC_SPEED_FAST

#define DEFAULT_ENC_SPEED_FAST_DIV 2 ; (2: divider = 2^(7-2) = 32)

; This DIN map allows you to customize the MB64E application to different hardwares

; The MB64E dump structure allows the use of up to 64 buttons, they are grouped to 8 buttons per shift register

; Define the used shift registers for the buttons here

; the shift registers are counted from one - means: 1 for the first, 2 for the second, etc...

; mark unused button groups with 0

;; NOTE: by default, the first two DIN shift registers are used for the encoders

#define DEFAULT_DIN_SR_PIN_01_08 2

#define DEFAULT_DIN_SR_PIN_09_16 3

#define DEFAULT_DIN_SR_PIN_17_24 1

#define DEFAULT_DIN_SR_PIN_25_32 4

#define DEFAULT_DIN_SR_PIN_33_40 5

#define DEFAULT_DIN_SR_PIN_41_48 6

#define DEFAULT_DIN_SR_PIN_49_56 7

#define DEFAULT_DIN_SR_PIN_57_64 8

;

; Datawheel for menu navigation/data entry connected or not?

; A datawheel can replace the left/right buttons!

; if 0: datawheel not connected

; if >= 1: encoder number assigned to datawheel function

; don't forget to check the pins of the datawheel in MIOS_ENC_PIN_TABLE (-> mios_tables.inc or setup_*.asm)

; it has to be connected to pin 4 and 5 by default

#define DEFAULT_ENC_DATAWHEEL 0

;

; DIN pin numbers of menu buttons

#if DEFAULT_ENC_DATAWHEEL == 0

#define DEFAULT_DIN_MENU_EXEC 7 ; menu exec button assigned to DIN pin #7

#define DEFAULT_DIN_MENU_RIGHT 6 ; menu right button assigned to DIN pin #6

#define DEFAULT_DIN_MENU_LEFT 5 ; menu left button assigned to DIN pin #5

#define DEFAULT_DIN_MENU_SNAPSHOT 4 ; menu snapshot button assigned to DIN pin #4

#else

#define DEFAULT_DIN_MENU_EXEC 7 ; menu exec button assigned to DIN pin #7

#define DEFAULT_DIN_MENU_SNAPSHOT 6 ; menu snapshot button assigned to DIN pin #4

#define DEFAULT_DIN_MENU_RIGHT 5 ; NOT USED - overlayed by datawheel

#define DEFAULT_DIN_MENU_LEFT 4 ; NOT USED - overlayed by datawheel

#endif

;

; This DOUT map allows you to customize the MB64E application to different hardwares

; The MB64E dump structure allows the use of up to 64 LEDs, they are grouped to 8 LEDs per shift register

; Define the used shift registers for the LEDs here

; the shift registers are counted from one - means: 1 for the first, 2 for the second, etc...

; mark unused LED groups with 0

;; NOTE: by default, the first four DOUT shift registers are used for the encoders

#define DEFAULT_DOUT_SR_PIN_01_08 1

#define DEFAULT_DOUT_SR_PIN_09_16 2

#define DEFAULT_DOUT_SR_PIN_17_24 3

#define DEFAULT_DOUT_SR_PIN_25_32 4

#define DEFAULT_DOUT_SR_PIN_33_40 5

#define DEFAULT_DOUT_SR_PIN_41_48 6

#define DEFAULT_DOUT_SR_PIN_49_56 7

#define DEFAULT_DOUT_SR_PIN_57_64 8

;

;

; Some menus are providing the possibility to use 16 "general purpose" buttons

; for selecting a parameter - e.g. the Bank Select menu allows to directly change the

; Bank with these buttons. So long as you stay in this menu, the normal function of

; these buttons (triggering MIDI or SFB events) is disabled

; Define the two shift registers which are assigned to this function here:

; 0 disables the GP buttons (not recommented!)

#define DEFAULT_GP_DIN_SR0 7 ; first GP DIN shift register assigned to SR#2

#define DEFAULT_GP_DIN_SR1 8 ; second GP DIN shift register assigned to SR#3

;

; above these buttons LEDs should be mounted to visualize the selected parameter

; (e.g. to visualize the bank which corresponds with the buttons below)

; Define the two shift registers which are assigned to this function here:

; 0 disables the GP LEDs (not recommented!)

#define DEFAULT_GP_DOUT_SR0 7 ; first GP DOUT shift register assigned to SR#5

#define DEFAULT_GP_DOUT_SR1 8 ; second GP DOUT shift register assigned to SR#6

;

; with following settings it is possible to center the screen on 2x20 and 2x40 LCDs

; see also the functional description of MIOS_LCD_YAddressSet

; recommented values:

; 2x16 | 2x20 | 4x20 | Comments

; -----+------+------+----------

#define DEFAULT_YOFFSET_LINE0 0x00 ; 0x00 | 0x02 | 0x42 | cursor pos: 0x00-0x0f

#define DEFAULT_YOFFSET_LINE1 0x40 ; 0x40 | 0x42 | 0x16 | cursor pos: 0x40-0x4f

#define DEFAULT_YOFFSET_LINE2 0x14 ; 0x14 | 0x16 | 0x02 | cursor pos: 0x80-0x8f (not used yet)

#define DEFAULT_YOFFSET_LINE3 0x54 ; 0x54 | 0x56 | 0x56 | cursor pos: 0xc0-0xcf (not used yet)

;

; The morphing function uses addresses within the MIOS address range which are

; reserved for the AIN handler.

; NOTE: morphing is automatically disabled if analog pots/faders are connected

#define DEFAULT_MORPH_FUNCTION_ENABLED 1

;

; Although MIDIbox64E has been designed for rotary encoders, it can also handle with

; up to 64 pots/faders or up to 8 motorfaders.

; Pots and faders are mapped to the "encoder" entries 64-128.

; Example: if group width is 16, and group 1 is selected, encoders are using

; entry 1-16, and pots are using entry 64-70

; NOTE: morphing is automatically disabled if analog pots/faders are connected

#define DEFAULT_NUMBER_AIN 8

;

; you could enable the multiplexers here to test this application

; with a MIDIbox64 based hardware

; if 0: no multiplexers (a *must* when MF module connected)

; if 1: use multiplexers

#define DEFAULT_ENABLE_AIN_MUX 0

;

; motorfaders connected?

; if 0: MF module disabled

; if 1: MF module enabled

#define DEFAULT_ENABLE_MOTORDRIVER 1

;

; The well known motorfader calibration values -- can also be changed "online" in the calibration menu

#define DEFAULT_MF_PWM_DUTY_UP 0x01 ; PWM duty cycle for upward moves (see http://www.ucapps.de/mbhp_mf.html)

#define DEFAULT_MF_PWM_DUTY_DOWN 0x01 ; PWM duty cycle for downward moves (see http://www.ucapps.de/mbhp_mf.html)

#define DEFAULT_MF_PWM_PERIOD 0x03 ; PWM period (see http://www.ucapps.de/mbhp_mf.html)

;

;

; following settings configure the touch sensors

; The DIN shift register to which the 8 touch sensors are connected has to be defined here

; Shift Register 9-16: touch sensor changes won't trigger the MBMF button handler

; no MIDI event will be sent

; Shift Register 1-8: touch sensor changes will trigger the MBMF button handler

; 0: touch sensor disabled

#define DEFAULT_TOUCH_SENSOR_SR 0

;

; Now define one of three behaviours (note: value can be changed "online" in the TS mode menu)

; The TS mode works independent from the MBMF button handler, means: use TOUCH_SENSOR_SR >= 8

; to suspend the motors w/o allocating a button function

;

; TOUCH_SENSOR_MODE EQU 0: no additional action when touch sensor pressed/depressed

; TOUCH_SENSOR_MODE EQU 1: the motor will be suspended via MIOS when the appr. touch sensor

; is pressed, so that it will not be moved on incoming MIDI events

; TOUCH_SENSOR_MODE EQU 2: like mode 1, additionally no MIDI event will be sent when the

; touch sensor is *not* pressed.

;

; Mode "1" is used by default to avoid circular troubleshooting requests in the MIDIbox forum from people

; who don't read this information before starting the application.

; Mode "2" should be the prefered setting if your touch sensors are working properly

#define DEFAULT_TOUCH_SENSOR_MODE 0

;

; The touch sensor sensitivity (can also be changed "online" in the "Touch Sensor" menu)

#define DEFAULT_TOUCH_SENSOR_SENSITIVITY 3

#endif

; ==========================================================================

;

; Copyright © 1998-2003 Thorsten Klose (Thorsten.Klose@midibox.org)

; http://www.uCApps.de

;

; ==========================================================================

;

; This file is part of MIDIbox64E

;

; MIDIbox64E is free software; you can redistribute it and/or modify

; it under the terms of the GNU General Public License as published by

; the Free Software Foundation; either version 2 of the License, or

; (at your option) any later version.

;

; MIDIbox64E is distributed in the hope that it will be useful,

; but WITHOUT ANY WARRANTY; without even the implied warranty of

; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

; GNU General Public License for more details.

;

; You should have received a copy of the GNU General Public License

; along with MIDIbox64E; if not, write to the Free Software

; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

;

; ==========================================================================

;; ---[ MIOS header file ]---

#include "mios.h"

;; ---[ useful macros ]---

#include "macros.h"

;; ---[ vectors to MIOS functions (never change!) ]---

#include "mios_vectors.inc"

;; ---[ user hooks (never change!) ]---

#include "user_vectors.inc"

;; ==========================================================================

;; General Application Settings

;; ==========================================================================

;; ---[ variables used by application ]---

#include "app_defines.h"

; ==========================================================================

;; ---[ configuration table for MIDI processor and rotary encoders ]---

#include "mios_tables.inc"

;; ---[ Custom LCD driver ]---

#include "app_lcd.inc"

;; ==========================================================================

;; Standard MIOS hooks

;; ==========================================================================

;; --------------------------------------------------------------------------

;; This function is called by MIOS after startup to initialize the

;; application

;; --------------------------------------------------------------------------

USER_Init

;; initialize the shift registers

movlw 0x10 ; use all shift registers

call MIOS_SRIO_NumberSet

movlw 0x01 ; set update frequncy to 1/1 mS

call MIOS_SRIO_UpdateFrqSet

movlw DEFAULT_SRIO_DEBOUNCE_CTR ; set debounce counter

call MIOS_SRIO_DebounceSet

;; the touch sensor sensitivity is defined in the SysEx dump (see MB64E_presets.inc)

;; and will be set in MB64E_dump.inc

movlw DEFAULT_TOUCH_SENSOR_SENSITIVITY

call MIOS_SRIO_TS_SensitivitySet

;; ------------------------------------------------------------------

;; initialize the AIN driver

movlw DEFAULT_NUMBER_AIN

call MIOS_AIN_NumberSet

#if DEFAULT_ENABLE_AIN_MUX

call MIOS_AIN_Muxed ; service multiplexer interface

#else

call MIOS_AIN_UnMuxed ; don't use multiplexer interface

#endif

movlw 0x03 ; set deadband to 3

call MIOS_AIN_DeadbandSet

#if DEFAULT_ENABLE_MOTORDRIVER

;; initialize the MF driver

call MIOS_MF_Enable

movlw 0x03 ; set MF deadband to 3

call MIOS_MF_DeadbandSet

movlw DEFAULT_MF_PWM_DUTY_UP

call MIOS_MF_PWM_DutyCycleUpSet

movlw DEFAULT_MF_PWM_DUTY_DOWN

call MIOS_MF_PWM_DutyCycleDownSet

movlw DEFAULT_MF_PWM_PERIOD

call MIOS_MF_PWM_PeriodSet

#endif

;; ------------------------------------------------------------------

;; get device ID

#if DEFAULT_AUTO_DEVICE_ID == 0

;; from EEPROM

movlw (EEPROM_READONLY & 0xff) + 1

movwf EEADR

call MIOS_EEPROM_Read

#else

;; from MIOS

call MIOS_MIDI_DeviceIDGet

#endif

andlw 0x07

movff WREG, MB64E_DEVICE_ID

;; initialize application specific variables

clrf MB_STAT

;; load values from internal dump

call MB64E_DUMP_RestoreAll

;; init control surface

call CS_MENU_Init

;; init default LCD offsets

call MB64E_LCD_SetDefaultOffsets

;; if "snapshot at poweron" flag is set, request it here

SET_BSR MB64E_BASE

bcf MB_STAT, MB_STAT_SNAPSHOT_REQ

btfsc MB64E_CFG1, MB64E_CFG1_SNAPSHOT_AT_POWERON, BANKED

bsf MB_STAT, MB_STAT_SNAPSHOT_REQ

;; ------------------------------------------------------------------

return

;; --------------------------------------------------------------------------

;; This function is called by MIOS in the mainloop when nothing else is to do

;; --------------------------------------------------------------------------

USER_Tick

;; ---[ check BankStick status ]---

call MB64E_BANK_CheckStick

;; ---[ if snapshot has been requested, send it here ]---

IFSET MB_STAT, MB_STAT_SNAPSHOT_REQ, call MB64E_PATCH_Send

bcf MB_STAT, MB_STAT_SNAPSHOT_REQ

#if DEFAULT_ENABLE_MOTORDRIVER

;; ---[ if fader positions should be updated, do it here ]---

call MB64E_FADER_CheckUpdate

#endif

return

;; --------------------------------------------------------------------------

;; This function is periodically called by MIOS. The frequency has to be

;; initialized with MIOS_Timer_Set

;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0

;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!

;; --------------------------------------------------------------------------

USER_Timer

return

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a debug command has been received

;; via SysEx

;; Input:

;; o WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3 like

;; specified in the debug command

;; Output:

;; o return values WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3

;; --------------------------------------------------------------------------

USER_MPROC_DebugTrigger

return

;; --------------------------------------------------------------------------

;; This function is called by MIOS when the display content should be

;; initialized. Thats the case during startup and after a temporary message

;; has been printed on the screen

;; --------------------------------------------------------------------------

USER_DISPLAY_Init

;; request an initialization

bsf CS_STAT, CS_STAT_DISPLAY_INIT_REQ

;; continue at the control surface menu handler

goto CS_MENU_Handler

;; --------------------------------------------------------------------------

;; This function is called in the mainloop when no temporary message is shown

;; on screen. Print the realtime messages here

;; --------------------------------------------------------------------------

USER_DISPLAY_Tick

;; continue at the control surface menu handler

goto CS_MENU_Handler

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a complete MIDI event has been received

;; Input:

;; o first MIDI event byte in MIOS_PARAMETER1

;; o second MIDI event byte in MIOS_PARAMETER2

;; o third MIDI event byte in MIOS_PARAMETER3

;; --------------------------------------------------------------------------

USER_MPROC_NotifyReceivedEvent

;; continue at MB64E MIDI handler

goto MB64E_MIDI_NotifyReceivedEvent

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a MIDI event has been received

;; which has been specified in the CONFIG_MIDI_IN table

;; Input:

;; o number of entry in WREG

;; o first MIDI event byte in MIOS_PARAMETER1

;; o second MIDI event byte in MIOS_PARAMETER2

;; o third MIDI event byte in MIOS_PARAMETER3

;; --------------------------------------------------------------------------

USER_MPROC_NotifyFoundEvent

return

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a MIDI event has not been completly

;; received within 2 seconds

;; --------------------------------------------------------------------------

USER_MPROC_TO_STR_0 STRING 16, 0x00, " MIDI Time Out! "

USER_MPROC_TO_STR_1 STRING 16, 0x40, " Whats up ??? "

USER_MPROC_NotifyTimeout

;; print timeout message

TABLE_ADDR USER_MPROC_TO_STR_0

call MIOS_LCD_PrintMessage

call MIOS_LCD_PrintMessage

;; request display update

bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ

;; -> jump to "ActionInvalid" for a proper reset of the sysex parser

goto MB64E_SYSEX_ActionInvalid

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a MIDI byte has been received

;; Input:

;; o received MIDI byte in WREG and MIOS_PARAMETER1

;; --------------------------------------------------------------------------

USER_MPROC_NotifyReceivedByte

;; -> continue at MB64E sysex parser

goto MB64E_SYSEX_Parser

;; --------------------------------------------------------------------------

;; This function is called by MIOS before the transfer of a MIDI byte.

;; It can be used to monitor the Tx activity or to do any other actions

;; (e.g. to switch a pin for multiplexed MIDI Outs) before the byte will

;; be sent.

;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0

;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!

;; Input:

;; o transmitted byte in WREG

;; --------------------------------------------------------------------------

USER_MIDI_NotifyTx

;; branch to Rx/Tx handler

goto MIDI_RXTX_NotifyTx

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a MIDI byte has been received.

;; It can be used to monitor the Rx activity or to do any action - e.g.

;; to react on realtime events like MIDI clock (0xf8) with a minimum latency

;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0

;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!

;; Input:

;; o received byte in WREG

;; --------------------------------------------------------------------------

USER_MIDI_NotifyRx

;; branch to Rx/Tx handler

goto MIDI_RXTX_NotifyRx

;; --------------------------------------------------------------------------

;; This function is called by MIOS when an button has been toggled

;; Input:

;; o Button number in WREG and MIOS_PARAMETER1

;; o Button value MIOS_PARAMETER2:

;; - 1 if button has been released (=5V)

;; - 0 if button has been pressed (=0V)

;; --------------------------------------------------------------------------

USER_DIN_NotifyToggle

#if DEFAULT_TOUCH_SENSOR_SR > 0

;; call TS update function if touch sensor has been pressed/depressed

rrf MIOS_PARAMETER1, W

rrf WREG, W

rrf WREG, W

andlw 0x0f

xorlw DEFAULT_TOUCH_SENSOR_SR - 1

skpnz

call MB64E_TS_Handler

#endif

;; else branch to the MB64E button handler

;; (NOTE: this function changes MIOS_PARAMETER[12] -- if additional

;; handlers should be called from this hook, place them before

;; this goto instruction)

goto MB64E_BUTTON_Handler

;; --------------------------------------------------------------------------

;; This function is called by MIOS when an encoder has been moved

;; Input:

;; o Encoder number in WREG and MIOS_PARAMETER1

;; o signed incrementer value in MIOS_PARAMETER2:

;; - is positive when encoder has been turned clockwise

;; - is negative when encoder has been turned counter clockwise

;; --------------------------------------------------------------------------

USER_ENC_NotifyChange

#if DEFAULT_ENC_DATAWHEEL

;; branch to CS_MENU_Enc if datawheel

movlw DEFAULT_ENC_DATAWHEEL - 1

IFNEQ MIOS_PARAMETER1, ACCESS, rgoto USER_ENC_NotifyChange_NoWheel

USER_ENC_NotifyChange_Wheel

;; expects incrementer in WREG

movf MIOS_PARAMETER2, W

goto CS_MENU_Enc

USER_ENC_NotifyChange_NoWheel

#endif

;;else continue at ENC handler

movf MIOS_PARAMETER1, W

goto MB64E_ENC_Handler

;; --------------------------------------------------------------------------

;; This function is called by MIOS before the shift register are loaded

;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0

;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible

;; --------------------------------------------------------------------------

USER_SR_Service_Prepare

;; call LEDrings handler

call MB64E_LEDRINGS_Handler

;; branch to the Rx/Tx LED handler

goto MIDI_RXTX_Handler

;; --------------------------------------------------------------------------

;; This function is called by MIOS after the shift register have been loaded

;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0

;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible

;; --------------------------------------------------------------------------

USER_SR_Service_Finish

;; ---[ handle with control surface variables (flashing cursor, etc) ]---

goto CS_MENU_TIMER

;; --------------------------------------------------------------------------

;; This function is called by MIOS when a Pot has been moved

;; Input:

;; o Pot number in WREG and MIOS_PARAMETER1

;; o LSB value in MIOS_PARAMETER2

;; o MSB value in MIOS_PARAMETER3

;; --------------------------------------------------------------------------

USER_AIN_NotifyChange

;; convert 10-bit value to 7-bit value

rrf MIOS_PARAMETER3, F ; value / 2

rrf MIOS_PARAMETER2, F

rrf MIOS_PARAMETER3, F ; value / 2

rrf MIOS_PARAMETER2, F

rrf MIOS_PARAMETER3, F ; value / 2

rrf MIOS_PARAMETER2, F

bcf MIOS_PARAMETER2, 7 ; clear 8th bit

;; now: pot number in WREG and MIOS_PARAMETER1

;; 7-bit value in MIOS_PARAMETER2

;; branch to fader handler

goto MB64E_FADER_Handler

;; ==========================================================================

;; Application code (see comments in files)

;; ==========================================================================

;; ---[ reusable utility functions ]---

#include "midi_evnt.inc"

#include "midi_rxtx.inc"

;; ---[ Control surface functions ]---

#include "cs_menu_buttons.inc"

#include "cs_menu_enc.inc"

#include "cs_menu_timer.inc"

#include "cs_menu.inc"

#include "cs_menu_tables.inc"

;; ---[ Menu pages handlers ]---

#include "cs_m_display.inc"

#include "cs_m_bank.inc"

#include "cs_m_patch.inc"

#include "cs_m_channel.inc"

#include "cs_m_learn.inc"

#if DEFAULT_NUMBER_AIN == 0 && DEFAULT_MORPH_FUNCTION_ENABLED == 1

#include "cs_m_morph.inc"

#endif

#include "cs_m_encmode.inc"

#include "cs_m_encspeed.inc"

#include "cs_m_ledrp.inc"

#include "cs_m_ts.inc"

#include "cs_m_tsmode.inc"

#include "cs_m_cali.inc"

#include "cs_m_bname.inc"

#include "cs_m_event.inc"

#include "cs_m_label.inc"

#include "cs_m_copy.inc"

#include "cs_m_midicfg.inc"

#include "cs_m_sysex.inc"

;; ---[ MB64E kernel ]---

#include "mb64e_bank.inc"

#include "mb64e_sysex.inc"

#include "mb64e_enc.inc"

#include "mb64e_fader.inc"

#include "mb64e_ts.inc"

#include "mb64e_buttons.inc"

#include "mb64e_leds.inc"

#include "mb64e_ledrings.inc"

#include "mb64e_lcd.inc"

#include "mb64e_msg.inc"

#include "mb64e_patch.inc"

#include "mb64e_fsr.inc"

#include "mb64e_addr.inc"

#include "mb64e_mem.inc"

#include "mb64e_dump.inc"

#include "mb64e_midi.inc"

#include "mb64e_meta.inc"

#include "mb64e_sfb.inc"

;; ---[ mb64e presets stored in Flash/EEPROM ]---

#include "mb64e_presets.inc"

END

------------------------------------------------------------------------------------------

Quand vous avez terminé avec main.asm.

5-faire un clique droit sur le dossier Header Files-->Add Files, ouvrir le dossier midibox64e_v2_2 et faire un ctrl A pour tout sélectionner les fichiers, cliquer sur ouvrir et tous les fichiers vont apparaître dans le dossier Header Files.

6-Cliquer 2X sur le fichier mios_tables.inc

C'est ici où on change les codes des encodeurs rotatifs

Voici ma config: Attention tout dépend comment vous soudez vos encodeurs

Moi, j'ai soudé mes encodeurs à partir du SR9 au SR16 et un encodeur sa prend 2 pins sur le Shift Registrer

Ex: ENC_ENTRY 9, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 1

mon premier encodeur==>V-Pot 1 est souder sur le SR9==>ENC_ENTRY 9,

pin D6 et D7==>6, MIOS_ENC_MODE_NON_DETENTED==>sans détente mécanique.

Pour les Pins:

0=pin D0 et D1

2=pin D2 et D3

4=pin D4 et D5

6=pin D6 et D7

==========================================================================

#ifndef SEPERATE_SETUP_FILE

org 0x3280 ; never change the origin!

;; --------------------------------------------------------------------------

;; In this table DIN pins have to be assigned to rotary encoders for the

;; MIOS_ENC driver

;;

;; up to 64 entries are provided

;;

;; The table must be terminated with an ENC_EOT entry. Unused entries should

;; be filled with ENC_EOT

;;

;; ENC_ENTRY provides following parameters

;; o first parameter: number of shift register - 1, 2, 3, ... 16

;; o second parameter: number of pin; since two pins are necessary

;; for each encoder, an even number is expected: 0, 2, 4 or 6

;; o the third parameter contains the encoder mode:

;; either MIOS_ENC_MODE_NON_DETENTED

;; or MIOS_ENC_MODE_DETENTED

;;

;; Configuration Examples:

;; ENC_ENTRY 1, 0, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 0 and 1 of SR 1

;; ENC_ENTRY 1, 2, MIOS_ENC_MODE_DETENTED ; detented encoder at pin 2 and 3 of SR 1

;; ENC_ENTRY 9, 6, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 6 and 7 of SR 9

;; --------------------------------------------------------------------------

;; encoder entry structure

ENC_ENTRY MACRO sr, din_0, mode

dw (mode << 8) | (din_0 + 8*(sr-1))

ENDM

ENC_EOT MACRO

dw 0xffff

ENDM

MIOS_ENC_PIN_TABLE

;; encoders 1-16

;; SR Pin Mode

ENC_ENTRY 9, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 1

ENC_ENTRY 9, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 2

ENC_ENTRY 10, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 3

ENC_ENTRY 10, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 4

ENC_ENTRY 11, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 5

ENC_ENTRY 11, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 6

ENC_ENTRY 12, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 7

ENC_ENTRY 12, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 8

ENC_ENTRY 9, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 9

ENC_ENTRY 9, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 10

ENC_ENTRY 10, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 11

ENC_ENTRY 10, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 12

ENC_ENTRY 11, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 13

ENC_ENTRY 11, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 14

ENC_ENTRY 12, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 15

ENC_ENTRY 12, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 16

;; encoders 17-32

ENC_ENTRY 13, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 17

ENC_ENTRY 13, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 18

ENC_ENTRY 14, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 19

ENC_ENTRY 14, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 20

ENC_ENTRY 15, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 21

ENC_ENTRY 15, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 22

ENC_ENTRY 16, 6, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 23

ENC_ENTRY 16, 4, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 24

ENC_ENTRY 13, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 25

ENC_ENTRY 13, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 26

ENC_ENTRY 14, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 27

ENC_ENTRY 14, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 28

ENC_ENTRY 15, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 29

ENC_ENTRY 15, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 30

ENC_ENTRY 16, 0, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 31

ENC_ENTRY 16, 2, MIOS_ENC_MODE_NON_DETENTED ; V-Pot 32

;; encoders 33-48

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

;; encoders 49-64

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

ENC_EOT

#endif

org 0x3300 ; never change the origin!

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Une fois terminé vous enregistrez votre projet et cliquez sur Build All une espèce d'enveloppe avec 2 petites flèches bleus vers le bas.

Et là normalement tout devrait être ressemblé, s'il n'y a pas d'erreur.

7-Ouvrir Mios Studio et charger le fichier main.hex que vous venez d'assemblé qui se trouve dans midibox64e_v2_2.

Voilà, j'espère que ça marchera pour vous!!!.

Je ferais un autre tuto avec les statuts de LED

Edited by djsampling
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...