Electronic – How to interface with a bus that’s powered when the rest of the circuit is off

bufferspi

I'm working on interfacing to a SPI bus that is exhibiting some… bad behavior.

The bus comes from a control box on a toy drumset. The control box is the SPI master, and it can be turned on and off with a built-in button. A separate circuit that reads from the drumpads is the only slave on the bus.

What I am doing is this: I have basically added a master to the bus, in the form of a microcontroller. I know that this isn't a standard use of SPI, but it is for a hobby project, so I don't care. The two masters never operate simultaneously, so there are no conflicts. I mostly enforce this: If the control box is on, I don't plug in the USB cable to the microcontroller (I'm using a Pro Micro). Also, if the microcontroller detects the control box is on, the uC will end SPI communications.

Here is my circuit. I still need to buffer the MISO line, but other than that it's what I'm using.

enter image description here

There are three states this circuit can be in:

  1. Off – control box is off and the Pro Micro is unplugged
  2. Control box power – The control box is on, but the Pro Micro is off, thanks to the Schottky diode. The control box is the master, and the Pro Micro is isolated from the circuit.
  3. Pro Micro power – The USB cable is plugged in, and the Pro Micro is the master. The control box is off.

My issue occurs during state 1. Although the control box is off, the SPI lines coming out of it are showing 3.3V. For some reason, the control box powers MOSI, CLK, and CS even though its VCC shows 0V! When neither the control box nor Pro Micro is on, the buffer is unpowered, and the outputs are seeing 3.3V. Somehow this is reverse-powering the buffer, which in turn powers the rest of my circuit.

I'm using a SN74AHC125 buffer.

Before I started using the buffer, I connected the SPI lines directly to my microcontroller (ATMega 32U4). I had the same problem: The SPI lines powered my Pro Micro through the reverse protection diodes on the pins.

So how can I drive these lines when they are still powered while the rest of my circuit is off?

Best Answer

Ok, I've solved this. I've added buffers between the control box and the drumpad controller. This is in addition to the buffers between the microcontroller and the drumpad controller.

So, the buffer configuration on (one) of the lines would look like this, with other parts of the circuit omitted for demonstrational purposes.

enter image description here

The unconnected pins on the buffers are the output enable pins, which I didn't connect (again, demonstrational purposes).

This circuit solves the problem because there is never power on the output of a buffer when the buffer isn't powered. Therefore, no reverse flow occurs.