Electronic – Why does the MCU work better when powered to Vcc and PA1=D2 instead of Vcc and GND

attinygroundmicrocontrollermidipower

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?

enter image description here

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%!

Best Answer

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.

enter image description here

(Source: datasheet)