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 ...
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???)
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???)