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?