MT8816 based effects router
http://www.midibox.org/forum/index.php/topic,10247.0.html
Re: MT8816 based effects router
http://www.midibox.org/forum/index.php/topic,10247.msg94551.html#msg94551
Long post ahead (sorry):
Although I’m just learning this particular uController, I got the impression that one can control the various ports on the PIC using “C”, no need for ASM. Check this:
http://www.midibox.org/forum/index.php/topic,11705.msg94362.html#msg94362
Perhaps that lowers the threshold for you to rework this project.
So controlling the MT8816 with a parallel port would be better?
We could for instance use:
This could be:
LATB pin [0, 6] (output latch B) = [J15:D0, J15:D6]
or
LATA pin [0, 3] & RA5 & LATE pin [0, 2] (output latch A & latch E) = [J5:A0, J5:A6].
This could be:
LATB pin 7 (output latch B) = J5:D7
or
LATE pin 2 (output latch E) = J5:A7
This could be:
LATD pin 7 (output latch D) = J5:E
or
LATC pin 0 (output latch C) = J6:RC / J7RC
-
Perhaps 1 pin for CS when using multiple MT8816 chips. When only using one, just keep it active (HIGH).
-
Perhaps 1 pin for RESET although I think that one is not needed, just keep it inactive (LOW).
Then, for instance, setup one switch in the switch matrix with one C function and two input arguments, that does:
/////////////////////////////////////////////////////////////////////////////
// SetSwitch
// Enables or disables one switch in the MT8816 switch matrix. (pseudo-code)
//
// byte switchAddress [in] Address of the switch to set: [0, 127].
// bool enable [in] Enable (true) or disable (false) the switch.
/////////////////////////////////////////////////////////////////////////////
void SetSwitch( byte switchAddress, bool enable )
{
/////////////
// Init: Has to be done only once so move this to a more appropriate function like:
// void Init(void) __wparam.
// Assume using J15 => LATB & LATD.LATD7
// Set the whole port as an output:
TRISB = 0;
TRISD.TRISD7 = 0;
// Select the MT8816 chip (if needed):
// MT8816.CS = 1;
// Deactivate RESET (if needed):
// MT8816.RESET = 0;
// End Init
/////////////
// Set STROBE to LOW (just to be sure):
// MT8816.STROBE = 0;
LATD.LATD7 = 0;
// Address the switch:
// MT8816.SWITCH = switchAddress;
LATB = switchAddress;
// Enable / disable the switch:
// MT8816.DATA = enable;
LATB.LATB7 = enable;
// Stobe the switch data:
// Set STROBE to HIGH:
// MT8816.STROBE = 1;
LATD.LATD7 = 1;
// Set STROBE to LOW:
// MT8816.STROBE = 0;
LATD.LATD7 = 0;
}
Memory usage:
PIC18F4620:
Flash (bytes) = 64K
Single-Word Instructions = 32768
SRAM (bytes) = 3986
EEPROM (bytes) = 1024
Is the SRAM the available data memory for an application (I’m not sure yet)? I’ll just assume it is for now.
One switch matrix “patch” (=how all 127 switches are setup) needs:
8 * 16 = 128 bits = 16 bytes
The position of the bit “tells” us for which switch needs to be enabled/disabled.
So we can store lots (>200) patches.
/////////////////////////////////////////////////////////////////////////////
// SetPatch
// Setup all 127 switches in the MT8816 switch matrix. (pseudo-code)
//
// double byte patchData [in] The states for all 128 switches.
/////////////////////////////////////////////////////////////////////////////
void SetPatch( double byte patchData )
{
// Iterate over all 128 switches and set each switch:
for( byte switchAdress = 0; switchAdress < 128; switchAdress = switchAdress + 1 )
{
// Set one switch of the patch:
bool enable = patchData.switchAddress;
SetSwitch( switchAddress, enable );
}
}
Now, I haven’t touched the “user interface” yet…