MIDI Serial2 and pullups issue

adrian

Well-known member
I have a strange issue linked to internal pullups and using Serial2 aka RX2/TX2 aka pins 9 and 10 for midi.... The following code (using *MIDI 4.2 library*) compiles but the midi does not work ...

Code:
#include <MIDI.h>

const uint8_t switchesPinTable [15] {2, 14, 7, 8, 6, 15, 22, 23, 9, 3, 4, 5, 11, 16, 17}; // list of PULLUP_SWITCHES

//MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiA);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midiB);

void setup() {
 // midiA.begin(MIDI_CHANNEL_OMNI);
  midiB.begin(MIDI_CHANNEL_OMNI);
  for (int i = 0; i < 15; i++)
  {
    delay(1);
    pinMode(switchesPinTable [i], INPUT_PULLUP );
  }
  
}
void loop() {
  midiB.read();
}

If I comment out the loop that sets the pinmode (i.e. internal pullups), then the midi *does* work. But why should that be, when I am not pulling up pins 9 or 10.

Funnily enough, if I use RX1/TX1 (pins 0 and 1) then everything is fine ... I can use the pinmode loop.

The obvious answer is using external pullups when using RX2/TX2, but I would rather not, since I have 13 switches to pullup ...

I am using a 'proper' midi circuit on the pins, but I have omitted the protection diode across the input ...seems to work ok except in the usage case above (i.e. when I enable my list of pullups using Serial1) .... why should that diode make any difference (if indeed that is the problem???)

WP_20160130_001.jpg
 
Code:
const uint8_t switchesPinTable [15] {2, 14, 7, 8, 6, 15, 22, 23[U],[B] 9[/B], [/U]3, 4, 5, 11, 16, 17}; // list of PULLUP_SWITCHES
}

If I comment out the loop that sets the pinmode (i.e. internal pullups), then the midi *does* work. But why should that be, when I am not pulling up pins 9 or 10.

Just scanning the code and the PinTable - #9 is listed there - i.e. RX2 ?
 
OH HELL ...I don't know how many times I looked t that list, and didn't see the 9 ...so sorry. and thanks. I think I may be going mad ..
 
LOL. I swear I checked the table three times at least. Then I immediately dived into a mysterious analog world ..midi-chlorians and all.
 
Back
Top