user31105: I am trying to build a setup with an Arduino Mega, having a DMX output (using DMXSimple library), and a MIDI library (to be done).
I was wondering, if I get into problems. According to This question, where Majenko's answer mentions that FastLED holds interrupts, I wonder if I can get into problems if I try to read MIDI data from 3 serial ports while sending DMX.
Probably FastLED (for led strips) and DMX (250 kbps) have some similarity. DMXSimple works with just one data line (no UART), but MIDI is using UART (31.25 kbps), 3 UARTS.
My fear is that everything works separately (I tried it before, long time ago with MIDI), but when I try to combine it, I get timing problems.

user4143: Yes, it does disable interrupts when sending a byte:
#if defined(__AVR__)
void dmxSendByte(volatile uint8_t value)
{
  uint8_t bitCount, delCount;
  __asm__ volatile (
    "cli\n"                            <<==== DISABLE INTERRUPTS
    "ld __tmp_reg__,%a[dmxPort]\n"
    "and __tmp_reg__,%[outMask]\n"
    "st %a[dmxPort],__tmp_reg__\n"
    "ldi %[bitCount],11\n" // 11 bit intervals per transmitted byte
    "rjmp bitLoop%=\n"     // Delay 2 clock cycles. 
  "bitLoop%=:\n"\
    "ldi %[delCount],%[delCountVal]\n"
  "delLoop%=:\n"
    "nop\n"
    "dec %[delCount]\n"
    "brne delLoop%=\n"
    "ld __tmp_reg__,%a[dmxPort]\n"
    "and __tmp_reg__,%[outMask]\n"
    "sec\n"
    "ror %[value]\n"
    "brcc sendzero%=\n"
    "or __tmp_reg__,%[outBit]\n"
  "sendzero%=:\n"
    "st %a[dmxPort],__tmp_reg__\n"
    "dec %[bitCount]\n"
    "brne bitLoop%=\n"
    "sei\n"                             <<==== ENABLE INTERRUPTS
    :
      [bitCount] "=&d" (bitCount),
      [delCount] "=&d" (delCount)
    :
      [dmxPort] "e" (dmxPort),
      [outMask] "r" (~dmxBit),
      [outBit] "r" (dmxBit),
      [delCountVal] "M" (F_CPU/1000000-3),
      [value] "r" (value)
  );
}

Also that routine is run from within a timer interrupt routine. On AVR with no interrupt priorities even without disabling interrupts it would still be blocking all other software from running.

31105: <p>I am trying to build a setup with an Arduino Mega, having a DMX output (using DMXSimple library), and a MIDI library (to be done).</p>

<p>I was wondering, if I get into problems. According to <a href="https://arduino.stackexchange.com/questions/67377/arduino-bluetooth-communication-is-slowing-down-because-of-the-for-loop/67378?noredirect=1#comment144972_67378">This question</a>, where Majenko's answer mentions that FastLED holds interrupts, I wonder if I can get into problems if I try to read MIDI data from 3 serial ports while sending DMX.</p>

<p>Probably FastLED (for led strips) and DMX (250 kbps) have some similarity. DMXSimple works with just one data line (no UART), but MIDI is using UART (31.25 kbps), 3 UARTS.</p>

<p>My fear is that everything works separately (I tried it before, long time ago with MIDI), but when I try to combine it, I get timing problems.</p>
 4143: <p>Yes, it does disable interrupts when sending a byte:</p>

<pre><code>#if defined(__AVR__)
void dmxSendByte(volatile uint8_t value)
{
  uint8_t bitCount, delCount;
  __asm__ volatile (
    "cli\n"                            &lt;&lt;==== DISABLE INTERRUPTS
    "ld __tmp_reg__,%a[dmxPort]\n"
    "and __tmp_reg__,%[outMask]\n"
    "st %a[dmxPort],__tmp_reg__\n"
    "ldi %[bitCount],11\n" // 11 bit intervals per transmitted byte
    "rjmp bitLoop%=\n"     // Delay 2 clock cycles. 
  "bitLoop%=:\n"\
    "ldi %[delCount],%[delCountVal]\n"
  "delLoop%=:\n"
    "nop\n"
    "dec %[delCount]\n"
    "brne delLoop%=\n"
    "ld __tmp_reg__,%a[dmxPort]\n"
    "and __tmp_reg__,%[outMask]\n"
    "sec\n"
    "ror %[value]\n"
    "brcc sendzero%=\n"
    "or __tmp_reg__,%[outBit]\n"
  "sendzero%=:\n"
    "st %a[dmxPort],__tmp_reg__\n"
    "dec %[bitCount]\n"
    "brne bitLoop%=\n"
    "sei\n"                             &lt;&lt;==== ENABLE INTERRUPTS
    :
      [bitCount] "=&amp;d" (bitCount),
      [delCount] "=&amp;d" (delCount)
    :
      [dmxPort] "e" (dmxPort),
      [outMask] "r" (~dmxBit),
      [outBit] "r" (dmxBit),
      [delCountVal] "M" (F_CPU/1000000-3),
      [value] "r" (value)
  );
}
</code></pre>

<p>Also that routine is run from within a timer interrupt routine. On AVR with no interrupt priorities even without disabling interrupts it would still be blocking all other software from running.</p>
