2
\$\begingroup\$

I have two microcontrollers, the beloved ATmega328p and an ATtiny85. The ATtiny85 does power management (toggling power to main MCU, get buttons clicks, and other things). The ATtiny85 disconnects VCC from the main MCU.

The main MCU (ATmega328p) is connected to the ATtiny85 to send a power-off signal. When it's connected directly (simple trace) it will drain current from the ATtiny85 to the ATmega328p.

Is there a way to prevent current sink from one MCU to the other?

Here is what I tried to solve this problem.

  1. I added a simple MOSFET to act as a switch (it kind of solves my problem, but that is not an elegant solution; what if I need 12 GPIOS?)
  2. I tried various resistors to limit current, but it will never be 0.

Another thing that I'm thinking about is to control ground and not VCC, But if the ATtiny85's control pin state is LOW, then it's effectively ground, right? Current sinking will continue.

I already optimized my board for a single MCU. This problem will be gone with a new batch of prototypes, but I still want to know how to prevent it if I have to do it that way.

Terribly drawn schematic

\$\endgroup\$
3
  • 2
    \$\begingroup\$ The main MCU (ATmega328p) is connected to the ATtiny85 to send a power-off signal. When it's connected directly (simple trace) it will drain current from the ATtiny85 to the ATmega328p. can you elaborate this? What do you mean by "drain current", and at what signal levels this happen? \$\endgroup\$ Commented Apr 6, 2023 at 6:37
  • 2
    \$\begingroup\$ This sounds needlessly complicated like a typical "XY question". This is, you need to solve problem X and you think Y is the solution, but you can't get Y working so you ask about how to fix that solution instead of actually asking about how to solve problem X which was the task all along. Why exactly do you need 2 MCUs? \$\endgroup\$
    – Lundin
    Commented Apr 6, 2023 at 6:37
  • \$\begingroup\$ Well, Main MCU will get powered on by Attiny85 GPIO pin when it should be powered off, since there is no power to Atmega328p VCC pin it takes power from Attiny85 Gpio pin. Signal level is 5V \$\endgroup\$ Commented Apr 6, 2023 at 6:45

2 Answers 2

2
\$\begingroup\$

The simplest solution to this case would be to invert the "power off" signal, i.e. turning it into a "power on" signal, that goes low when the ATMEGA is to be shut down.

It does not matter that the GPIO on the ATTINY is sinking, as long as there is no way of supplying current into the ATMEGA. Also, the ATMEGA is still grounded "normally", so there is really no difference due to sinking the GPIO.

Another way would be to simply set the Power Off signal low, moments before turning off the MOSFET and then include some delay in the ATMEGA software to not act on that low signal as fast. Then it will be powered off before it has a chans of acting on the signal. (the reason for doing it before and not right after powering off is to make there is not any time that the ATMEGA is supplied through the GPIO, as this might cause damage to the devices if the current is to high)

A more universal solution that might work in other cases is to isolate the GPIO when power is shut down. I've done this using an analog switch in some applications. Although, care must be taken so that this switch does not itself draw too much current in a battery supplied application like this.

\$\endgroup\$
1
  • \$\begingroup\$ This is very helpful, thank you. \$\endgroup\$ Commented Apr 6, 2023 at 6:50
2
\$\begingroup\$

Halfway between a comment and an answer, but here goes:

Why do you want to prevent (a very small) current going from one MCU to another? Where is the problem?

The ATtiny can tell the ATmega to go into (deep) sleep, and the input pin of the ATmega is very high-impedance; current draw will be negligible, and once the signal has been sent and the ATmega is shutting down you can set the ATtiny's output pin to high-impedance if you want and no current at all will flow anymore. Where is the problem?

You can alternatively use the ATtiny and a MOSFET to switch off the power supply to the ATmega. This doesn't allow the ATmega to shut down gracefully, but as far as current goes: the MOSFETs gate current will be negligible once it has switched. Where is the problem?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think supply voltage is also being disconnected from the ATMega. As such, its internal Vcc rail is unpowered and near ground, so the input protection diodes will pass current into Vcc if any GPIO is significantly above ground. \$\endgroup\$ Commented Apr 6, 2023 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.