STM32F405 Data Sheet Confusion

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Hi guys,

It’s been a while since I been in circuit design and I am so lost in this STM32F405 Data Sheet, but I am trying to make this circuit that turns on an IR Emitter.

I can’t choose my MOSFET unless I know what voltage the STM32f405 pins can output. I want to PWM it as shown in the picture, but for some reason I can not figure out the Max “Output” Voltage the I/O pins can output. I tried looking in the data sheet, but all I could see is “Table 49. Output Voltage Characteristics.” It doesn’t say the min and max you can PWM out the pins. Where do I find this?

Table 11 Talks about it, but it only gives the Input Voltage Characteristics, not the Input.

Also kind of strange it says +4 on that table. So it’s telling me that The Max on a 5V tolerant pin is (3.3V+4V)= 7.3V…That doesn’t sound right for a 5V tolerant pin??? Where am I reading this wrong?

Also I can’t seem to find the Read V High and V Low values. I know it is 90 and 10 percent of VDD normally, but this is an I/O pin. How do I find this?

Thank you in advanced.
Sorry, I’m confusing myself. -_-


Help.PNG
 

Attachments

ElectricSpidey

Joined Dec 2, 2017
1,961
Choose a good logic level MOSFET and don't worry about it.

100mA is not a big deal so the transistor won't need to have much gate charge, but most people still use a small gate resistor to protect the micro pin.

If you can set the pin as push/pull you don't really need the pulldown, unless you have other considerations.

Anyway, current is your bigger concern than voltage, as long as you use a logic level MOSFET.
 

MrChips

Joined Oct 2, 2009
24,609
STM32F405 is a 3.6V device.

GPIO output voltages will be just just within 0-VDD range (3.3 or 3.6V).
Use a logic level MOSFET.
R1 will have to be about 10Ω in order to deliver 100mA @ 1.5V to the LED.
 

Irving

Joined Jan 30, 2016
2,308
Use a logic level MOSFET.
Agreed, but many so-called logic-level MOSFETs are still spec'd as Vgs = 3 or 4v. which makes them pretty poor on 3.3v MCU.

2N7000 is commonly used, but is rubbish @3v Ron = 5ohm, Id=50mA
My current favourites:
TO92 case: ZVN4210 Vds=100v, Id=450mA, Ron = <2ohm @ Vgs=2.5v
TO92 case: TN0610 Vds=20v, Id=750mA, Ron<2ohm @Vgs=3v
TO220 case: IRL3803, Vds=30v, Id>50A, Ron<0.02ohm. Good for id>10A @ Vgs=3v, no heatsink needed < 5A
All through-hole for breadboard/perf-board.
There are better options with SMT parts, though many are thermally limited to <1A
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Thank you a ton everyone! I am now on a better path of understanding. I didn't know they were called GPIO pins I am learning as I go along. I also don't understand why it is SO HARD to find good information on this. The data sheet doesn't even give reference schematics for the F405. I only found one for the in the getting started pdf online, but that is on an STM32F469. Even Teensy has more docs...Unless I just don't know where to look.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
So I guess the only think remaining is that I am very confused with finding a MOSFET.
Lets take my circuit for instance.
Lets says I have this:

  • SFH4545
    • Source Voltage: 5V
    • Vf(typ): 2.3V
    • Vf(max): 3V
    • If: 100mA
      If you calculate the resistor value for that it is 27Ohm. Here is my issue. I know you can open the gate fully, but during the period before it saturates, the current wont be full. That resistor is dependent on that MOSFET. How do you find a MOSFET that works with the desired current? It would see to me that you would want a Vth as close to the Min of a High Signal? The amps needs to be equal to or larger than your desired current. What else do I need to know? This is where I am lost. I have forgotten so much from college.




      Also I see a lot of other people light LEDs on the GPIO pins. How is that done.
      Another example would be:
    • Green LED: 150060GS75000
      • Source Voltage: 5V
      • Vf: 3.2
      • If: 20mA
      • Intensity: 430mcd
      • R= (3.3-3.2V)/(20ma)=5Ohm, but I see others put a 1K on their circuit. Why? The 3.2 is not the max, it's the typical.
Thanks in advanced. I hope that made sense.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
We are discussing output voltages.

VOL = output at logic low will not exceed 0.4V
VOH = output at logic high will not be below VDD - 0.4V

under the stated conditions (sourcing or sinking 8mA).
Not read, Output*. :)
But is my logic correct on what I stated above for the outputs?
For this scenario:

VOL = output at logic low will not exceed 0.4V
VOH = output at logic high will not be below 2.9V

Just to make sure I am following correctly.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Agreed, but many so-called logic-level MOSFETs are still spec'd as Vgs = 3 or 4v. which makes them pretty poor on 3.3v MCU.

2N7000 is commonly used, but is rubbish @3v Ron = 5ohm, Id=50mA
My current favourites:
TO92 case: ZVN4210 Vds=100v, Id=450mA, Ron = <2ohm @ Vgs=2.5v
TO92 case: TN0610 Vds=20v, Id=750mA, Ron<2ohm @Vgs=3v
TO220 case: IRL3803, Vds=30v, Id>50A, Ron<0.02ohm. Good for id>10A @ Vgs=3v, no heatsink needed < 5A
All through-hole for breadboard/perf-board.
There are better options with SMT parts, though many are thermally limited to <1A
Thank you a ton for posting this. I ended up going through these data sheets and trying to understand why you picked them.

This is my conclusion. If I want to find a MOSFET that I can turn it completely on around 3.3V, so I can have the most control over how much current passes through it with a GPIO pin, then I allow I really need to do is find a MOSFET where VGSth(max) is a little under 3.3V?

Or is this the wrong way to think of it?

Basically what I want is to have this configuration:
GPIO Out(3.3V): Id of 100mA or more, right
GPIO Out(Around 1V): Id of around 50mA

In addition the my R1 resistor is simply a Current "Limiting" resistor, right? There is no dependency on the MOSFET?

I basically want to control my LEDs and SFH 4545 with as much control.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Agreed, but many so-called logic-level MOSFETs are still spec'd as Vgs = 3 or 4v. which makes them pretty poor on 3.3v MCU.

2N7000 is commonly used, but is rubbish @3v Ron = 5ohm, Id=50mA
My current favourites:
TO92 case: ZVN4210 Vds=100v, Id=450mA, Ron = <2ohm @ Vgs=2.5v
TO92 case: TN0610 Vds=20v, Id=750mA, Ron<2ohm @Vgs=3v
TO220 case: IRL3803, Vds=30v, Id>50A, Ron<0.02ohm. Good for id>10A @ Vgs=3v, no heatsink needed < 5A
All through-hole for breadboard/perf-board.
There are better options with SMT parts, though many are thermally limited to <1A
Sorry for the second question.

I'm confusing myself with the VGSth=VDS
An example:
https://assets.nexperia.com/documents/data-sheet/BSS87.pdf
ID = 1 mA; VDS = VGS

But how can they say that at VDS = VGS it is 1ma?
If you look at the Id vs Vds chart, where VGS=VDS, lets say (VGS=VDS=2V), it is at 100mA....so where does the 1mA come from? Even at (VGS=VDS=3V), that is around 900mA. I am trying to get this range, but Digi key is putting this 1mA...Sorry, I know i'm confusing myself.
 

Irving

Joined Jan 30, 2016
2,308
Yes, it can be confusing. Vgs(th), the gate threshold voltage is the voltage at which the MOSFET is deemed to be turned off - the Id quoted is the 'leakage' current at a spec'd Vgs/Vd. All that means is a voltage > than Vgs(th) is turning the MOSFET on; it doesn't mean that it is fully on. The output characteristics graph Fig6 shows, typically, that with, say, a Vgs of 2.5v the MOSFET's Id is independent of Vds above ~1.5v . If you wanted an Id of 100mA then Vgs of >2.5v suffices while 2v might not.

For more info on interpreting these charts read from page 11 onwards in the application note AN11158 attached.

1625046755235.png
 

Attachments

Last edited:

Irving

Joined Jan 30, 2016
2,308
Here is a simulation that might help your understanding. This plots Vds and Id versus Vgs as that is incremented from 0.5 to 5v. Below about 1.5v the MOSFET is definitely off. Id = 0. Between 1.75 and 2.5v the MOSFET is gradually switching on, Vds is dropping, Id is increasing... until above 2.5v it is essentially fully on. The lower plot shows the effective Rds(on) resistance, and the power dissipated in the MOSFET, and shows why it is important to drive the gate with sufficient voltage.

1625055939568.png

This second simulation shows the effect trying to increase the drain current without sufficient gate voltage. At 2.5 - 3v its not able to turn on fully, resulting in a higher channel resistance and massive internal dissipation. This is the thermal limit for the BSS87; its not a great MOSFET for use with 3.3v MCU except at small drain currents.

1625057013039.png
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
an be confusing. Vgs(th), the gate threshold voltage is the voltage at which the MOSFET is deemed to be turned o
Here is a simulation that might help your understanding. This plots Vds and Id versus Vgs as that is incremented from 0.5 to 5v. Below about 1.5v the MOSFET is definitely off. Id = 0. Between 1.75 and 2.5v the MOSFET is gradually switching on, Vds is dropping, Id is increasing... until above 2.5v it is essentially fully on. The lower plot shows the effective Rds(on) resistance, and the power dissipated in the MOSFET, and shows why it is important to drive the gate with sufficient voltage.

View attachment 242478

This second simulation shows the effect trying to increase the drain current without sufficient gate voltage. At 2.5 - 3v its not able to turn on fully, resulting in a higher channel resistance and massive internal dissipation. This is the thermal limit for the BSS87; its not a great MOSFET for use with 3.3v MCU except at small drain currents.

View attachment 242484
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Here is a simulation that might help your understanding. This plots Vds and Id versus Vgs as that is incremented from 0.5 to 5v. Below about 1.5v the MOSFET is definitely off. Id = 0. Between 1.75 and 2.5v the MOSFET is gradually switching on, Vds is dropping, Id is increasing... until above 2.5v it is essentially fully on. The lower plot shows the effective Rds(on) resistance, and the power dissipated in the MOSFET, and shows why it is important to drive the gate with sufficient voltage.

View attachment 242478

This second simulation shows the effect trying to increase the drain current without sufficient gate voltage. At 2.5 - 3v its not able to turn on fully, resulting in a higher channel resistance and massive internal dissipation. This is the thermal limit for the BSS87; its not a great MOSFET for use with 3.3v MCU except at small drain currents.

View attachment 242484
Thank you so much for plotting this!
I finally understand this now.
Ended up going through the data sheets you posted and studied them.

The only thing that is confusing me is that you said the MOSFET isn't good for a 3.3V.
Then I would need a MOSFET with a lower Vth, right?

I want a plot more like the second with the lower resistance because you get a larger turning on range (Linear Range)IDS. I want to have as much resolution in my control over the current. Now you said this is a poor choice.

Is that because you used 12V for the drain side instead of 5V? Sorry I mean to say 5V for the source of the drain.

I ended up picking an ON Semiconductor BSS138 and installed LTSpice to try and simulate it. I got the majority of it setup, but I have no idea how to use the spice model for the BSS138. When I opened it there are a bunch of different models instead of one representing the component. I got the SFH4545 set up, but the BSS138, is a little confusing.
This is as far as I was able to get:
 

Irving

Joined Jan 30, 2016
2,308
Basically what I want is to have this configuration:
GPIO Out(3.3V): Id of 100mA or more, right
GPIO Out(Around 1V): Id of around 50mA
I want a plot more like the second with the lower resistance because you get a larger turning on range (Linear Range)IDS. I want to have as much resolution in my control over the current. Now you said this is a poor choice.
Ah, I see your further confusion... you are thinking of PWM output as a voltage level. Its not, its a pulse... it can be converted to a voltage for specific applications by exernal circuitry but thats not how you control the brightness of an LED. You control the brightness by varying the on-off ratio (duty cycle). The LED is always fully on when switched on and fully off when switched off. The brightness is the average amount of light output. As long as the pulse rate is above about 120Hz most people can't discern any flicker.

You should never treat a general-purpose switching MOSFET as a variable resistor except for very small currents; it should always be on or off. There are specialist linear MOSFETs for high-power current control but thats not what you need here. The brightness of an LED controlled by current is highly non-linear and of very narrow range.

Now to your specific LEDs.

The green LED can be driven directly from the GPIO on 5v MCUs, but 20mA is considered to be the absolute max sink or source current for a GPIO output and shouldn't be done if you're using more than 3 or 4 this way to avoid overheating the MCU. That's why many use a 1k, the reduced current doesn't significantly reduce the brightness, if its used solely as an on or off indicator, however a nominally 3.2v Vf green LED will probably not light up on a 3.3v MCU unless driven off the 5v rail with MCU sinking rather than sourcing current (and remembering that GPIO off/low = LED on! So a resistor of (5-3.2-.4)/.008 = 175ohm). If you want to control the brightness with PWM then a higher current is beneficial, but then you should consider an external switch.

The SFH4545 is a very different beast and you must pay close attention to the datasheet, particularly the operating conditions and the thermal considerations. The 100mA forward current is not continuous, but this isn't a device you would normally aim to control the brightness of, it is intended for full output pulsed operation. What is your application? If you need more help on this, its a full post in its own right so let me know.
 
Last edited:

Thread Starter

SDTricker

Joined Jul 2, 2016
18
The green LED can be driven directly from the GPIO on 5v MCUs, but 20mA is considered to be the abso
with MCU sinking rather than sourcing current (and remembering that GPIO off/low = LED on! So a resistor of (5-3.2-.4)
Wow, this really shows how much I have forgotten. Shame on me!
Thank you so much for helping me out with this, and sorry I took so long to thank you.
You really have helped me get this back in my head. I feel stupid now. haha
idk what I was thinking when I was thinking about a MOSFET as a way to control the brightness.
Shows how much I should never forget to review the theory.

So I have decided to ditch the Green LEDs and I am using all Red LEDs.
These are the specs of My Red LEDs:
  • Vf: 2V
  • If: 20mA

So what I decided to do is to run the LEDs off the MCUs, so I can control the brightness....? ...? lol I'll get this.
This is my calculation:
Lets say I want to run the Red LEDs off the MCU and have a current of 10mA to save some current draw on the MCU.
(3.3V-2V)(20mA) = 65. The next highest resistor is around 100Ohm. I thought the pins could output 25mA as per table 12 Current Characteristics???

150060RS86000.PNG
Peripherals.PNG

This is much lower than 1K Ohm.
Where am I going wrong with my logic?


For my SFH4545:
These are my calculations:
20210707_030333.jpg

Emitter.PNG

Could you please give me a Sanity Check on this? I keep changing it all the time when I figure out something new.

Should I make a new post for this?


Finally, what do you mean by an external switch to control the brightness of the LEDs?

Again, thank you so much for taking the time to help me unravel the confusion in my head! I am lucky! :D
 

Irving

Joined Jan 30, 2016
2,308
Lets say I want to run the Red LEDs off the MCU and have a current of 10mA to save some current draw on the MCU.
(3.3V-2V)(20mA) = 65. The next highest resistor is around 100Ohm. I thought the pins could output 25mA as per table 12 Current Characteristics???
The 25mA in table 12 is under the heading of "Absolute Maximum" ratings, the value you should consider is in table 49 as previously discussed, which suggests 8mA typically for a 0.4v delta from either GND or VDD. The other limiting factor is power loss in the MCU. At 20mA you're limited to around 10 GPIO outputs if running at max clock speed, up to around 12 if you slow the chip right down, and the voltage on the GPIO pin won't go above 2v or below 1.3v which means most LEDs won't work anyway if GPIO is sourcing current.

Its always better to sink current than source it. Then the LED can be connected to a higher voltage rail, eg 5v, than the 3.3v of the MCU which often comes from a small on-board regulator.

On a 5v rail, with Vol<=0.4v a high-efficiency red LED on a 1k resistor will take 3 - 4 mA which is plenty bright in a 1mm SMD LED or 2mm through hole device.

Why are you brightness controlling your 8 red LEDs? What purpose do they serve?

Coming back to your SFH5454, these are InfraRed LED, so why do you want to control their brightness, since you can't see it!
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
The 25mA in table 12 is under the heading of "Absolute Maximum" ratings, the value you should consider is in table 49 as previously discussed, which suggests 8mA typically for a 0.4v delta from either GND or VDD. The other limiting factor is power loss in the MCU. At 20mA you're limited to around 10 GPIO outputs if running at max clock speed, up to around 12 if you slow the chip right down, and the voltage on the GPIO pin won't go above 2v or below 1.3v which means most LEDs won't work anyway if GPIO is sourcing current.

Its always better to sink current than source it. Then the LED can be connected to a higher voltage rail, eg 5v, than the 3.3v of the MCU which often comes from a small on-board regulator.

On a 5v rail, with Vol<=0.4v a high-efficiency red LED on a 1k resistor will take 3 - 4 mA which is plenty bright in a 1mm SMD LED or 2mm through hole device.

Why are you brightness controlling your 8 red LEDs? What purpose do they serve?

Coming back to your SFH5454, these are InfraRed LED, so why do you want to control their brightness, since you can't see it!
Wow, I really am lucky to get your help on this. It can be difficult to find answers to this when you don't fully understand what you are looking for online.
Thank you again. I guess there are really nice people on this earth. haha :D

-"The 25mA in table 12 is under the heading of "Absolute Maximum" ratings, the value you should consider is in table 49 as previously discussed, which suggests 8mA typically for a 0.4v delta from either GND or VDD."
-I completely misunderstood that when that was said to me. Thank you for clarifying that. Now I understand. :)

-"the voltage on the GPIO pin won't go above 2v or below 1.3v which means most LEDs won't work anyway if GPIO is sourcing current."
Sorry for being a slow learner on this. Now I am really confused.
I thought the 0.4 was just for the range the voltage is in when high or low as in:
Min: It will read as a logic low from 0<->0.4
Max: It will read as a logic high from (3.3-0.4=2.9) = 2.9V<->3.3V
Obviously a higher voltage equates to a higher current with Ohm's law, but this doesn't matter because we have current limiting resistors. So why do we throw in the 0.4V into the equation when finding resistance if this is just a range? This would be calculating off a source of 2.9V instead of 3.3V. I thought GPIO can output 3.3V? Just in the range of 2.9<->3.3V on High?
Or did you stated that the "Voltage on the GPIO pin wont go above 2V or below 1.3V", "IF" you are running at 20mA? Is that what you were saying because of the power consumption on 20mA?

You stated: For a Green LED, (5-3.2-.4)/.008 = 175ohm
I understand now the current should stay around 8mA, but what I am still confused on is why you have to put the 0.4V? It thought it was just the range?


Now going back based off what you said with the current, recalculating this equates to(Red LED, Vf=2V):
1) Sourcing from 5V and sinking current: (5-2-.4)/.008 = 325Ohm
2) Sourcing current from GPIO pins to power as in the schematic above this is (3.3-2-.4)/.008 =112.5Ohm.
At 8mA, the LED is 300mcd which is about 1 lumen. This is plenty bright. My logic was off on this too.

But at a 1K resistor on the GPIO pin, this makes the current:
(3.3-2-.4)/ I =1000 Ohm = (0.9)/ (I) = 1000Ohm =(0.9)/1000Ohm = 900uA.
This is 900uA. Now I see people throw a 1K resistor on this all over schematics on GPIO pins. Then how can you even see the LED? How would 1K even work? Where is my confusion at?
 
Top