# Why does my MCU work better when powered to Vcc and PA1=D2 instead of Vcc and GND?

I'm making a MIDI processor, with its power coming ... directly from the MIDI signal itself, as done by the author of this page (see "Powered by MIDI" paragraph): it works well with a 100µF cap. I have assembled several units with no problem at all, perfectly working.

I'm using a ATtiny4313 and usually it's wired this way:

• VCC (pin 20) => + of the 100 µF cap
• GND (pin 10) => GND of MIDI sockets
• RX/D0 (pin 2) => MIDI IN (with the usual MIDI IN schematics involving an optocoupler and resistors)
• TX/D1 (pin 3) => MIDI OUT (with the usual MIDI OUT schematics too)

However on new units I'm currently assembling I noticed that it is not working very well (sometimes the MIDI signal is ok, sometimes it's not ok, and some notes are stuck, some are dropped).

Then, instead of the previous connection, I tried this way:

• VCC (pin 20) => + of the 100 µF cap
• PA1/D2 (pin 4) => GND of MIDI sockets
• RX/D0 (pin 2) => MIDI IN (with the usual MIDI IN schematics involving an optocoupler and resistors)
• TX/D1 (pin 3) => MIDI OUT (with the usual MIDI OUT schematics too)
• and nothing connected to GND of the ATtiny!

And miracuously, everything works perfectly, the MIDI signal is perfect, no lost or stuck note! I tried it during a long time and it's perfect like this.

Question: What could be the reason of this thing: the MCU works better when powered on VCC (pin 20) and PA1/D2 (pin 4), instead of VCC and GND?

PS: In my code, I did nothing with pin #4, no digitalWrite, no pinMode. The only thing present in my code relative to a pin is pinMode(7, INPUT_PULLUP);, because I might add a push button later.

PS2: I thought it would be a oscillator problem with the internal oscillator a little bit too much "off" and that adding a crystal would solve it, but then why would doing PA1/D2 (pin 4) ==> GND solve everything perfectly well, even without a crystal?

PS3: I read a few parts of the ATtiny 4313 datasheet without any clue about this mysterious situation, i.e. power it in an uncommon way and it works 100%!

• Please draw a schematic. Powering microcontrollers via data pins is very suspicious. Also if you are not aware MIDI devices are not meant to be powered from MIDI, that is not how a MIDI IN device should work according to MIDI examples, it only works if the MIDI out device is also made according to MIDI examples. So if you make a weird device, and connect it to device that is also weird, it just does not have to work.. Dec 5, 2019 at 21:09
• You are decoupling with a 100µF cap? Electrolytic? Is there some smaller ceramic somewhere?
– dim
Dec 5, 2019 at 21:10
• @dim Just an electrolytic 100µF cap, no smaller ceramic. I might try to add a smaller ceramic, but again this wouldn't explain it works perfectly well when PA1/D2 (pin 4) is connected to GND instead of pin 10. What a mystery!
– Basj
Dec 5, 2019 at 21:12
• @Justme Many very well-known-in-every-studio and perfectly-working MIDI processors are powered via MIDI only, see for example this one from a good brand: thomann.de/gb/midi_solutions_merger_v2.htm
– Basj
Dec 5, 2019 at 21:14
• @Basj reviews are product marketing garbage, of course the ones with "does not work for me" reviews get deleted or not submitted anyway. The cheap chinese USB to MIDI interfaces that have no optoisolator tend to work quite poorly. Dec 5, 2019 at 21:24

Powering it via IO pin protection diode would make the GND to be a diode drop higher than the IO pin voltage. It might work better because of how different devices have different MIDI OUT buffers, not all MIDI OUT interfaces are alike, some are driven with push-pull output drivers, some are driven with open-drain outputs.

(Source: datasheet)

• Thank you for your answer. How is connected this protection diode (which kind of diode?) between PA1/D2 and what?
– Basj
Dec 5, 2019 at 21:23
• Please open your AVR datasheet about IO pin structure which shows internal protection diodes from IO pin to GND and VCC. Dec 5, 2019 at 21:27
• Ok I'm looking this, thanks @Justme!
– Basj
Dec 5, 2019 at 21:31
• @Basj Look at the first picture there for example. For each GPIO, there are two diodes: one diverting any excess voltage to VCC and another diverting any excess negative voltage to GND. So you could power the MCU through those diodes, even though that's not recommended. See this project for a stunning example.
– dim
Dec 5, 2019 at 21:33
• @Justme I edited and added the schematic found in the datasheet for future reference, I hope it's ok for you.
– Basj
Dec 5, 2019 at 21:34