Electronics > Microcontrollers

driving external BJT using internal pull-up resistor?

(1/3) > >>

240RS:
I am using STM32G4's a lot and solder through-hole nucleo boards. If I drive quite some transistors (BC549C with high gain), I use 10k base resistor normally if I want to switch 6mA to ground (1/20th of collector current).

Would be nice if I could drive the transistor directly from the MCU without the base transistor and thought of the following: why not use the internal pull-up to switch the transistor on pull the output pin low for logical to switch the transistor off. Is that being done?

At powerup and down, I need to make sure the transistor is never switched on. Is there a risk that cannot be done by configuring the PWR registers correctly?

The only thing I am trying to do is save space by using less through-hole resistors.

Also, I want the the collector-emitter voltage to be as low as possible at 6mA and use a 1/20th base current as rule of thumb. With a higher gain transistor like the BC549C (hfe in the 100s), is this still 1/20th? The internal pull-up of the MCU seems to be around 40k. My ideal value was 10k.

Thanks!

wek:
I don't like the idea, but I am not a HW expert. If the datasheet-guaranteed maximum pullup resistance, minimum used VDD and datasheet-guaranteed minimum hfe at the datasheet-given Vce yields the required current, and if you don't need speed, well then maybe it's OK.

From the powerup/down point of view, the GPIO state during reset is not influenced by PWR or any other internal register, and is given in GPIO chapter of DS (with the extra USBC-PD caveat in 'G0/'G4). Most pins are floating/analog in 'G4 during and after reset, check the leakage table in datasheet and assert, if max leakage x maximum hfe won't result in exceedingly high current for your application. Note, that some pins (the JTAG/SWD ones) do have pullups/pulldowns switched on during reset.

Also from programming point of view, using pullups/pulldowns dynamically brings in atomicity problem, if you want to use it in interrupts (note that when using "normal" outputs, atomicity at hardware level is ensured by using GPIO_BSRR register).

JW

srb1954:

--- Quote from: 240RS on September 28, 2022, 08:10:49 am ---I am using STM32G4's a lot and solder through-hole nucleo boards. If I drive quite some transistors (BC549C with high gain), I use 10k base resistor normally if I want to switch 6mA to ground (1/20th of collector current).

Would be nice if I could drive the transistor directly from the MCU without the base transistor and thought of the following: why not use the internal pull-up to switch the transistor on pull the output pin low for logical to switch the transistor off. Is that being done?

At powerup and down, I need to make sure the transistor is never switched on. Is there a risk that cannot be done by configuring the PWR registers correctly?

The only thing I am trying to do is save space by using less through-hole resistors.

Also, I want the the collector-emitter voltage to be as low as possible at 6mA and use a 1/20th base current as rule of thumb. With a higher gain transistor like the BC549C (hfe in the 100s), is this still 1/20th? The internal pull-up of the MCU seems to be around 40k. My ideal value was 10k.



--- End quote ---
I wouldn't recommend using the internal pull-up resistors in the micro as they usually don't have a sufficiently well controlled resistance value to ensure adequate base current drive to your BJT. There is also a risk that the BJTs and the micro are damaged by excessive current if you accidentally configure the port O/Ps as a strong active push-pull drive and there is no resistor to limit the base current.

Considerable space saving could be made by using resistor arrays. Depending on your PCB design rules you save 50-75% of the space of discrete resistors.

Two other options that can completely eliminate base resistors are:
(a) Use a MOSFET and drive it directly from the micro O/P pin. You will need to ensure that the MOSFET is a low threshold device that can be fully turned on by the available output voltage swing of the micro port pin. Suitable low-threshold MOSFETs will likely be more expensive than a BJT and there is also a possibility that the MOSFET is inadvertently switched on by port leakage during the power-up process of the micro and until such time as the S/W sets the ports to O/Ps and to the correct inactive state.
(b) Use BJTs with internal bias resistors, sometimes known as 'digital transistors'. These are more predictable during power-up conditions as they incorporate an internal base-emitter resistor that will keep the transistor turned off while the micro is performing its power-up procedure.

240RS:
Thanks for the two posts. This concludes it for me: I will just use base resistors. Thanks. Learned a lot.

Peabody:
I have done that with other processors, and it has worked well.  But I only do hobby stuff, not production design.  In the end, you might want to just try it and see what happens.  If the internal pullup is 40K, and the DC gain of the transistor is at least 90, then switching 6mA should be no problem.  And if the GPIO pins are floating on powerup, I don't think the transistors will turn on, even momentarily.  That leads to the question of how you would turn the transistors off.  In theory, you could just disable the pullup so the port is floating.  Without base current, the transistor should turn off.  But in a very noisy environment, you might want to change the port to output, low.  Just be careful to change it back to input first to turn the transistor back on.  You don't want it to ever be output, high.

Well I'll defer to the judgement of the EEs here, but my suspicion is it would work just fine.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version