Hello,
Circuit Description:
I'm working on an Atmega328P-based project, logging data to an SD card. To save battery power, I would like to have the SD card switched with a transistor when sleeping for an extended period. I have wired up a 2n2222a NPN BJT transistor (MMBT2222A in sot-23 form) as a low-side switch, and I'm using a diode+1nF capacitor for clamping. SD schematic here:
Observed Behavior:
With no SD card inserted, I can toggle SWITCH_SD and nothing happens (as expected). With an SD card inserted, setting SWITCH_SD high causes the Atmega328P to reset. Inserting the SD card while SWITCH_SD is high also causes the same reset.
Questions:
Why is the circuit resetting, and how can I fix it?
Apparently SD cards can cause a huge inrush current of up to 200mA when they are first connected. I think this inrush was browning out my 3.3V power supply. I will add a dedicated switching power supply for the SD card 3.3V net to handle that.
Other options discussed were various filters, or soft-start switches. I hope this answer helps someone since I've seen similar questions unanswered. I'll update on how the dedicated supply goes.
I don't know if this makes any sense in electronics terms, but it seems as though suddenly dumping all that 3.3V charge to ground could cause a ground "spike", and from the processor's viewpoint, that could be interpreted as its Reset pin being grounded.
A high side switch sounds like a better option, but you have to be careful about what happens if the processor will ever be powered down while the separate supply is still powered up. In that situation, the protection diode in the processor will provide a direct path to Vcc, which will be at ground when Vcc is powered down. So if a PNP base is connected to a GPIO pin, the PNP will be turned on when the processor is powered down, which is not what you want. You may need a two stage base drive - the PNP base driven by an NPN transistor which will turn on only when the GPIO is high.