STM32 Pinout Polarity

Post here first, or if you can't find a relevant section!
Post Reply
b.aslan1983
Posts: 2
Joined: Sun Apr 28, 2024 6:33 am

STM32 Pinout Polarity

Post by b.aslan1983 »

Hello
I opened the issue here because I didn't know where to open it. Are the pin outputs of STM32 output + or -?
GonzoG
Posts: 460
Joined: Wed Jan 15, 2020 11:30 am
Answers: 32
Location: Prudnik, Poland

Re: STM32 Pinout Polarity

Post by GonzoG »

Depends on what you mean by "-".
1. Is it a negative voltage (in relation to GND) - then they are always >= 0V
2. or is it GND - then both. They can be + or -.
b.aslan1983
Posts: 2
Joined: Sun Apr 28, 2024 6:33 am

Re: STM32 Pinout Polarity

Post by b.aslan1983 »

Thank you for the answer.
3.3v does not come out from stm32 pin, gnd comes out. Isn't there 3.3v output?


Image
GonzoG
Posts: 460
Joined: Wed Jan 15, 2020 11:30 am
Answers: 32
Location: Prudnik, Poland

Re: STM32 Pinout Polarity

Post by GonzoG »

Don't treat GPIO pins as power source. They are not meant for this.

And yes, they can be set to low state (GND) or high (usually 3.3V).
ozcar
Posts: 149
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: STM32 Pinout Polarity

Post by ozcar »

For some other processors GPIO pins may not have symmetrical output capability. For example, they might be able to sink more current than they can source, and that could influence the way you might connect a LED to them.

However for the STM32 processors that I have used, the datasheets indicate equal sink and source capability. It is possible that some pins could be “weaker” than others though – for example, this is from the STM32F103x8/STM32F103xB datasheet: “The GPIOs (general-purpose inputs/outputs) can sink or source up to ±8 mA, and sink or source up to ±20 mA (with a relaxed VOL/VOH) except PC13, PC14 and PC15, which can sink or source up to ±3 mA.” (There are also limits to the sum of the currents sunk or sourced by all the pins). If you are using a pin like that I don’t know why in your diagram you indicate the second way of connecting a LED as “not working” (of course depending on which way you connect the LED, setting the pin HIGH say could either turn the LED on, or turn it off). Assuming you have not damaged the chip somehow.
ag123
Posts: 1798
Joined: Thu Dec 19, 2019 5:30 am
Answers: 28

Re: STM32 Pinout Polarity

Post by ag123 »

one should read datasheets e.g.
https://www.st.com/resource/en/datashee ... f103c8.pdf
5.2 Absolute maximum ratings
Output current sunk by any I/O and control pin 25 mA
Output current source by any I/Os and control pin − 25 mA

in fact it should be much less than this like 5 mA max, at 20 mA you risk the mcu overheating

5.3.13 I/O port characteristics
The GPIOs (general-purpose inputs/outputs) can sink or source up to ±8 mA, and sink or
source up to ±20 mA (with a relaxed VOL/VOH) except PC13, PC14 and PC15, which can
sink or source up to ±3 mA

----
- make sure you connect the LED in the correct way, there are lots of goofs connecting leds in reverse.
- use low voltage and low current LEDs it should light up with like 1-5 mA currents

if you need to source or sink more currents, use a transistor e.g. 2n2222
https://electronics.stackexchange.com/q ... s-a-switch
'cheap' (e.g. in the flea markets)
practically 100 pcs for a dollar or 2, and some even includes shipping
https://www.aliexpress.com/w/wholesale-2n2222.html

if you have lots of pins to switch my favourite is uln2003 7 pins or uln2803 8 pins
lots available and 'cheap' in the 'flea markets' as well.
https://www.st.com/resource/en/datasheet/uln2001.pdf
https://www.sparkfun.com/datasheets/IC/uln2803a.pdf
the main purpose is these are far more compact than bulky transistors if you need to switch more than a few lines.
Post Reply

Return to “General discussion”