How do you prevent ICs that are "turned off" from drawing parasitic power?

I recently have an issue with ICs that are supposed to be powered off (by p-channel mosfet) still drawing parasitic power. One such instance is an atmega328p that communicates with the main Arduino MEGA2560 via Serial2. When I turn it off, the power rail still has 3.6V. I thought the mosfet was broken and replaced it. Still no go, until I realized it was drawing parasitic power from Serial2. I disconnected it from Serial2 and immediately the power rail goes between 5V and 1.7V when I toggle the MOSFET. Still, there are other sources of parasitic power, via the reset pin? The reset pin of the atmega328p is tied to the reset of the Arduino MEGA2560. With that disconnected, 1.7V goes to 0V. So since the circuit is a shield, I disconnected it from Arduino MEGA 3560 and only connected up 5V, GND and the pin that toggles the MOSFET. Now the power rail toggles between 5V and ~0V.

So my question would be: how do you prevent an IC from drawing parasitic power?

I guess with Serial2, I can disable its TX, just set it to 0V, after I turn off the power to the atmega328p. I guess I should set brown out level at 4.2V to prevent atmega328p from actually trying to run at 3.6V. What about the reset? Controlling it with a pin on Arduino MEGA2560?

I use a 74LVC07A part that has something they call IOFF circuitry. When the IC is powered off its outputs become high impedance (not diode clamped I guess). I laid out a board, but never actually built it, so I'm not actually sure if it works the way I think it does, anyway look at some datasheets that have IOFF and see what you think.

"how do you prevent an IC from drawing parasitic power?"
Simple answer is: don't let the voltage on their IO pins exceed that of their VCC pins, then the IO clamp diodes will not conduct and power the internal their internal VCC bus.
How you keep the IO pins at 0 while it's VCC is at 0 can be done many ways.

Thanks CR.

I think for my current project, I figured out with some help:

  1. TX2 is supplying parasitic power. Turn off the UART hardware once I turn off power to the Atmega328p. Serial2.end() or cbi(UCSR2B,TXEN2);
  2. Reset is supplying a small amount of parasitic power. I'll have to update my board to have it controlled by a pin on Arduino MEGA2560.

What if I wanted to turn off an I2C device? The bus lines are pulled up by default so I can't just turn them off. Should I use some I2C switch to isolate each I2C device to be turned on/off?

If it were SPI, I would probably drive CS to LOW after I turn off the device.

Can you use a I2C source voltage driver that you can turn off? i.e couple of P-channel MOSFETs?

Do you mean that I should power the SCL and SDI via P-channel MOSFETS? I don't know what happens to the I2C devices that are still powered on if I power the bus down. I am just exploring the possibility of keeping some I2C devices on and the rest off.

CrossRoads:
Can you use a I2C source voltage driver that you can turn off? i.e couple of P-channel MOSFETs?

Now I start to get it. Do you mean to drive the bus with P-channel MOSET and couple with a second P-channel MOSFET that toggles the power on the first MOSFET?

Put a P-channel MOSFET between 5V and I2C pullup resistors. Maybe have it between everything you want to power down even.

OK got it. Thanks. I also found out that the Wire library turns on internal pullups so those need to be disabled as well.