I have the code below to regularly send out some MIDI values. I'm also maintaining 4 strings of 360 WS2813 LEDs using the octows2811 library on a teensy 3.5.
Building this on arduino 1.8.2 works as expected. But if I build the same thing on arduino 1.8.4 (with the appropriate teensyduino), the LEDs flicker madly. I can disable the MIDI output by failing to call midiloop() and all is well.
However, if I change the bytes in the structure below to ints, it also works on 1.8.4.
I suspect this is nothing to do with MIDI, but is related to the 3-byte structure size. Perhaps on 1.8.4, the structure is improperly aligned and is generating bus faults that screw with the DMA.
I realise the fragment below isn't enough to duplicate the problem, but if this isn't a known problem (I see there is now an arduino 1.8.5 to use) I'll try to make a minimal example that will show the problem up.
Building this on arduino 1.8.2 works as expected. But if I build the same thing on arduino 1.8.4 (with the appropriate teensyduino), the LEDs flicker madly. I can disable the MIDI output by failing to call midiloop() and all is well.
However, if I change the bytes in the structure below to ints, it also works on 1.8.4.
I suspect this is nothing to do with MIDI, but is related to the 3-byte structure size. Perhaps on 1.8.4, the structure is improperly aligned and is generating bus faults that screw with the DMA.
I realise the fragment below isn't enough to duplicate the problem, but if this isn't a known problem (I see there is now an arduino 1.8.5 to use) I'll try to make a minimal example that will show the problem up.
Code:
static struct MIDI_CHANNEL {
byte m_channel;
byte m_control;
byte m_value;
} midi_channels[MIDI_CHANNELS] =
{
{1, CONTROL_VOL, 0},
{2, CONTROL_VOL, 0},
{3, CONTROL_VOL, 0},
{4, CONTROL_VOL, 0},
{5, CONTROL_VOL, 0},
{6, CONTROL_VOL, 0},
{7, CONTROL_VOL, 0},
{8, CONTROL_VOL, 0},
{9, CONTROL_VOL, 0},
{10, CONTROL_VOL, 0},
};
void midisetup()
{
MIDI.begin(3);
}
// send the next midi command if time to send the previous one is exceeded
void midiloop( void)
{
static int chix = 0;
static uint32_t last_midi = 0;
if ((millis() - last_midi) > 0) {
//Serial.printf("chix %d ch %d cn %d val %d\n", chix, midi_channels[chix].m_channel, midi_channels[chix].m_control, midi_channels[chix].m_value);
MIDI.sendControlChange(midi_channels[chix].m_control, midi_channels[chix].m_value, midi_channels[chix].m_channel);
chix = (chix+1) % MIDI_CHANNELS;
last_midi = millis();
}
}
Last edited: