I am trying to find the current sunk and sourced by the GPIO pins of the STM32G030 (STM32G030x6/x8). It says on page 40 of the datasheet:
Current characteristics of microcontroller
The output current sunk by any I/O and control pin
When it says output current, it suggests the GPIO pin is outputting the current to whatever it is connected to it, but then it says sunk which makes it sound like the GPIO pin is drawing the current in? SO which does it mean?
On page 62 of the datasheet it says: Outout driving current
What does it mean relaxed VOL/VOH?
-
4\$\begingroup\$ I guess what they meant to say is that when you draw more current than 6mA (When GPIO work as a output) the VOL/VOH will be higher than specified in the datasheet. So if this heavily loaded output is connected to the input of a logic circuit the circuit will not be able to properly recognize Low or High states. \$\endgroup\$G36– G362021年11月11日 16:12:12 +00:00Commented Nov 11, 2021 at 16:12
-
1\$\begingroup\$ The output will sink the current if the load is connected between Vdd and output pin. And the output is at Low state. And the output will source the current if the load is connected between the output pin and GND and the output is at a High state. \$\endgroup\$G36– G362021年11月11日 16:21:58 +00:00Commented Nov 11, 2021 at 16:21
-
2\$\begingroup\$ "output current" doesn't mean "the GPIO pin is outputting the current", it means "the current when the pin is configured as an output" - as opposed to when the pin is configured as an input. \$\endgroup\$brhans– brhans2021年11月11日 16:28:11 +00:00Commented Nov 11, 2021 at 16:28
-
\$\begingroup\$ If you configure a GPIO as an input in your code, and the voltage applied to the GPIO is somewhere between 0 and VDD, then you will not need to worry about GPIO current limits. These limits come into play when you try to drive a high level into a short circuit (or small resistor) or if you have a short circuit to VDD but you try to drive the pin low. If you are using a GPIO to drive a load that needs to sink or source a lot of current, there are ways to do that with transistors or standalone logic buffers. \$\endgroup\$user57037– user570372021年11月11日 16:48:59 +00:00Commented Nov 11, 2021 at 16:48
-
\$\begingroup\$ It simply means that the pin can output two different voltages for ON and OFF. When OFF it can sink a maximum of 15mA, when ON it will provide a maximum of 15mA \$\endgroup\$slebetman– slebetman2021年11月12日 10:15:33 +00:00Commented Nov 12, 2021 at 10:15
5 Answers 5
You have a snippet from the Absolute Maximum ratings in the datasheet, which is more obvious in context:
So you should never exceed 15mA sink or source current from any pin. As well as that limitation the total current sourced or sunk must never exceed 80mA. So if you have 8 outputs, each sourcing 10 mA, that's right at the maximum limit for the chip (not advisable).
As with all "Absolute Maximum" ratings, you would be well advised to stay well away from them if you want good reliability.
The other ratings refer to what you can do and have predictable limits on the output voltage under sinking and sourcing conditions.
Those are well spelled out and explained in Table 50 - Vol for sinking 6mA or less is at most 0.4V, and Voh for sourcing 6mA or less is at least 2.4V with Vddio >= 2.7V. Similarly, the maximum drop is 1.3V for sink/source <15mA. Quite relaxed indeed, especially with a 2.7V Vddio.
And there are also limits for 3mA- the outputs are quite well characterized with guaranteed limits for several useful current ranges. Better than most.
The 15mA limits are perhaps useful if you're driving an LED directly and don't care too much about the exact current.
-
\$\begingroup\$ So if I have a 3.3V supply and a switch connected to the microcontroller, I have a 10k pull down to ensure when the switch is open, the pin does not float. I should also have a current limiting resistor which allows sort of the 3.3 supply to appear at the microcontroller pin (e.g. Allow 3V at pin, 6mA flowing into pin, therefore 0.3V across current limiting resistor, R=V/I =0.3V/6mA =50ohms)? \$\endgroup\$MRB– MRB2021年11月11日 16:37:45 +00:00Commented Nov 11, 2021 at 16:37
-
1\$\begingroup\$ @MRB normally, if you set up a GPIO as an input, it has high impedance to signals in the normal range from 0 to VDD. So a current limiting resistor would probably not be needed for an input. If you set the pin up as an output, and drive it low while the switch is closed, then you would need some kind of current limiting resistor. Not clear which case applies to you. \$\endgroup\$user57037– user570372021年11月11日 16:44:52 +00:00Commented Nov 11, 2021 at 16:44
-
\$\begingroup\$ What he said .. no current limiting required unless you want to cover the potential issue of an input inadvertently configured as an output. \$\endgroup\$Spehro 'speff' Pefhany– Spehro 'speff' Pefhany2021年11月11日 17:16:39 +00:00Commented Nov 11, 2021 at 17:16
Image source: ST AN4899 STM32 microcontroller GPIO configuration for hardware settings and low-power consumption
- Blue line : sourcing
- Red line : sinking
What does it mean relaxed VOL/VOH?
In my opinion it means that a pin can sink or source 6mA through body diodes, if for example the applied voltage on GPIO is greater than Vdd or it is lower than GND. But it can sink/source 15mA if transistors are in conduction mode, thus less resistance.
-
1\$\begingroup\$ @ilkkachu The two overlapping circles is a symbol for current source. While between Vdd and GND there is a voltage source (not depicted), so at the end both red and blue lines are closed to the GND. \$\endgroup\$Marko Buršič– Marko Buršič2021年11月11日 17:25:10 +00:00Commented Nov 11, 2021 at 17:25
-
1\$\begingroup\$ I think "relaxed VOL/VOH" means that you can sink or source up to 6mA while remaining within the VOL/VOH voltage range, but you can go up to 15mA if you want (it's perfectly fine), but the pin voltage won't still be in that voltage range so you should consider that when designing your circuit. \$\endgroup\$Stack Exchange Broke The Law– Stack Exchange Broke The Law2021年11月12日 12:52:47 +00:00Commented Nov 12, 2021 at 12:52
When it says output current, it suggests the GPIO pin is outputting the current to whatever it is connected to it, but then it says sunk which makes it sound like the GPIO pin is drawing the current in? SO which does it mean?
If there is (as an example) a pull-up resistor on the GPIO output then the GPIO will sink current into itself when it is trying to drive an output logic level of zero.
Sourcing current means outputting current to a 0 volt connected load. Sinking current means the current is reversed and flows from a positively biased load into the pin.
relaxed VOL/VOH means the logic "highs" and the "lows" will not reach within the same voltage to the supply rails as when sinking/sourcing lower currents (in which case it will be guaranteed to be within a certain maximum voltage to the rails, say within 0.3 Volts etc). This will limit the pull-up/down resistor values you can use to ensure a well defined low-to-high logic transition. Just make sure you don't use too low a pull-up/down resitor if you want well defined high/low voltage values.
-
1\$\begingroup\$ How do you know/ how can you make sure the microcontroller is using relaxed highs and lows or if the high and low will reach the supply rails (0v and 3.3V)? If I want the microcontroller to reach the voltage rails, I should use the 6mA value? \$\endgroup\$MRB– MRB2021年11月11日 16:24:40 +00:00Commented Nov 11, 2021 at 16:24
-
\$\begingroup\$ The spec is saying that the GPIO may safely sink or source up to 15 mA, but if you make it sink or source over 6 mA the output voltage may not meet the "official" High or Low voltage specs. \$\endgroup\$Peter Bennett– Peter Bennett2021年11月11日 16:29:34 +00:00Commented Nov 11, 2021 at 16:29
-
\$\begingroup\$ @MRB If you sink or source more than 6mA the voltage may sag or rise more than the VOH or VOL voltage says it should. With a high output and 6mA being sourced, you are guaranteed that the voltage is VOH or higher. But if you increase the current to 9mA, the voltage is no longer guaranteed to be VOH or higher. If you need the voltage to be VOH or higher, you can't draw more than 6mA. If you don't need that, you can draw up to 15mA. \$\endgroup\$Stack Exchange Broke The Law– Stack Exchange Broke The Law2021年11月12日 12:54:53 +00:00Commented Nov 12, 2021 at 12:54
-
\$\begingroup\$ Generally you will want to take a low-power consuption approach to your design, and so your pull-ups/downs should be high. If you wish to drive/sink devices with higher than 6mA than you may use buffers (gates/ BJTs, or MOSFETs) that will take the current you require, say even up to 100mA or more if required. Just be aware not to use the GPIOs for > 6mA that's all ... \$\endgroup\$citizen– citizen2021年11月15日 09:26:18 +00:00Commented Nov 15, 2021 at 9:26
When it says output current, it suggests the GPIO pin is outputting the current to whatever it is connected to it, but then it says sunk which makes it sound like the GPIO pin is drawing the current in? SO which does it mean?
The terminology here is:
- "Input" means that the chip is reading information in.
- "Output" means that the chip is sending information out.
- "Sink" means that the chip is pulling positive charge in.
- "Source" means that the chip is pushing positive charge out.
The most straightforward way for a chip to output information is for it to send a 0 by putting out a low voltage (in other words, trying to pull positive charge in) and to send a 1 by putting out a high voltage (in other words, trying to push positive charge out).
So, when the datasheet says "output current sunk: 15 mA," that means that when that pin is sending a 0 (by trying to pull positive charge in), you should not let more than 15 mA of positive charge go into it. Likewise, when the datasheet says "output current sourced: 15 mA," that means that when that pin is sending a 1 (by trying to push positive charge out), you should not let more than 15 mA of positive charge come out of it.