Electronic – Using a GPIO pin as a power source

gpsstm32

I have an STM32F2 (reference manual here) which is connected to a GPS receiver through 5 pins. One of these pins is a power supply pin for the GPS.

All pins on the micro-controller are GPIO pins that need to be configured. (E.g. configure as input, output, floating, open-drain, push-pull, etc.) The ARM reference manual does not discuss GPIO pins as power sources.

What GPIO configurations do I need to apply to a power supply pin?

Best Answer

Note:
This answer was originally written before we knew anything about the receiver, like its 1.8V power supply. Telaclavo's answer is good. As a more general answer the PNP/MOSFET solution remains; you don't want to power parts of your circuit from a microcontroller's I/O pin.

You don't want to do that! You'd configure the pin as output and make it high to provide power to the GPS receiver, but microcontrollers I/Os can only supply limited current, 25mA for the STM32F205xx (Section 6.2 page 72 of the datasheet), which will be too low for powering your (and any other) GPS receiver (34 to 38 mA, as stated in the datasheet)

Use the I/O pin to drive a PNP transistor which will supply the required current.

enter image description here

Note that using a PNP inverses your logic: a logic low will turn the receiver on.

I would not use an NPN for this. In common emitter it would mean that the receiver's ground is a few hundred mV above ground, and a circuit should have one single ground which is the same for every component. In common collector you would lose too much of your 3.3V power supply.

edit
Wouter would use a MOSFET instead of a BJT, and that's a good alternative. Just make sure you choose a logic-level FET, which will give you enough current at a \$V_{GS}\$ of -3.3V. The Rohm RZE002P02 is a suitable type. It will also have a lower voltage drop if your receiver needs less than about 200mA.

edit 2 (re clabacchio's addition of a datasheet)
This device operates at 1.8V, the STM32 at 3.3V. You can use an LDO with an enable input and control that from your microcontroller. No transistor needed. (Thanks for the suggestion, markrages.) You'll also need level shifters for the data.

Related Topic