This page was machine-translated and may differ from the original. View original
[Serial] ST Yuji Kawano Engineer (19) - How can an MCU directly drive a high-brightness LED?
High current port support MCU, LED driving
MCU maximum rating value/data sheet compliance required
PMOS high current port provided, switch use possible
MCU maximum rating value/data sheet compliance required
PMOS high current port provided, switch use possible
[Editor's Note] When we talk about semiconductors, we tend to think of semiconductors that are familiar to the general public, such as the CPU and memory of computers. On the other hand, MCUs (Micro Controller Units), which are core semiconductors used to operate electronic products, are semiconductors that are still unfamiliar to the general public, even though they are commonly used in all electronic products that we easily come across. These MCUs have recently been in the news due to the semiconductor shortage, and they are beginning to attract the attention of the general public. Accordingly, our magazine has prepared a place to learn about MCUs through a series of articles by Yuji Kawano, Manager of ST Microelectronics, a company specializing in MCU semiconductors.
How can we enable MCUs to directly drive high-brightness LEDs?
■ Answer
Among the MCU GPIOs (general purpose I/Os), there is a type called a high-current port. As the name suggests, this type can pass a large current; this type of GPIO is designed so that the MCU can directly drive LEDs, including high-brightness LEDs that generally require tens of mA of current. A single high-current port can pass currents from 15mA to 25mA; the maximum current is given in the MCU datasheet. By controlling two or three high-current ports in parallel simultaneously, currents of 50mA or 75mA can be passed through the output circuit.
However, the absolute maximum rating level specifies the maximum current that can be drawn from the power supply for the MCU; no current exceeding this value can ever pass. Figure 1 shows an example of two LED driver circuits using high-current ports. The circuit in Figure 1(a) uses one high-current port, and the circuit in Figure 1(b) uses two ports.

▲Figure 1: Example of LED distributor circuit
■ Description
○ LED driver circuit design
First, let's build a circuit that turns an LED on or off using a switch instead of an MCU. It uses two 1.5 V batteries as a power source to supply 3 V. Figure 2 shows this circuit. In order to design an electrical circuit, we need data on the electrical characteristics of the LED; in this case, the rated current level (mA) and the forward voltage Vf (V) for that current. A red LED has a rated current of 25 mA and a forward voltage of 1.4 V to 2.0 V. In order to use the LED stably, the LED current is set to 70% to 80% of the rated value. Therefore, we can calculate that the actual current I is 20 mA, which is 80% of 25 mA. When Vs=3.0V, Vf=1.4V, I=20mA, the current limiting resistor R can be obtained by (Vs-Vf)/I, and through this, we can calculate that R = (3.0V-1.4V)/20mA=80Ω. Therefore, we can drive the red LED stably enough by connecting an 80Ω resistor to the LED. When the switch is on, the LED turns on; when the switch is off, the LED turns off.

▲Figure 2: LED driver circuit example
○ LED driver circuit design using MCU
Next, let's build a circuit that turns an LED on or off using the MCU's GPIO instead of a switch. Figure 3 shows a driver circuit that uses the GPIO's NMOS as a switch.
The basic circuit structure is the same as the previous design, but the electrical characteristics of the circuit must be examined. Even if the ON resistance of the switch is 0, the ON resistance of the NMOS is not 0 Ω; the NMOS has a resistance of several Ω in the ON state. The ON resistance of the NMOS must be subtracted from the value obtained in the previous design, 80 Ω. Otherwise, this ON resistance will cause the small LED current to be less than 20mA, resulting in insufficient LED brightness.

▲Figure 3: Example of LED driver circuit (using 1 MCU GPIO)
How can I check the ON resistance of the high current port NMOS? It is listed in the MCU datasheet. First, you need to check whether the MCU supports the high current port; if not, the MCU cannot drive the high brightness LED. The GPIO characteristics table in the datasheet contains information about the high current port. The GPIO pass current is indicated by IOL or IOH. IOL is the current that can pass through the GPIO when the NMOS is turned on and outputs LOW; IOH is the current that can pass through the GPIO when the PMOS is turned on and outputs High. If you find data such as IOH=25mA or IOL=25mA, the GPIO is a high current port. The current value varies depending on the MCU and GPIO. Generally, the current for driving an LED is between 15mA and 25mA.
Next, when the NMOS of the GPIO turns ON, the GPIO outputs Low; this output voltage is called VOL (voltage output low). When the PMOS turns ON, the GPIO outputs High; this output voltage is called VOH (voltage output high). In this paper, since NMOS will be used as a switch, we will focus on VOL and IOL.
Let's look at the GPIO characteristics table. The measurement conditions in the VOL column indicate the IOL value. For example, the data sheet for STMicroelectronics' 32-bit MCU STM32 states that VOL = 1.3 V when IOL = 20 mA (see Figure 4(a)). According to Ohm's law, the ON resistance of NMOS is given as VOL / IOL = 1.3 V / 20 mA = 65 Ω.
The current-limiting resistor value in the previous design using a switch was 80Ω. Subtracting 65Ω from 85Ω gives 15Ω, which can be used as the current-limiting resistor required to achieve a current of 20mA, and is the same value as in the design using a switch.
When the GPIO outputs Low, the LED turns on, and when it outputs High, it turns off.
○ Other calculation methods (reference)
When 20mA of current passes through the NMOS, the terminal outputs a voltage of 1.3V, and in this case the voltage across the resistor and LED is 3.0V-1.3V=1.7V. Substituting the formula for R explained above and subtracting 1.7 V from 3.0 V gives us R = (1.7 V - 1.4 V) / 20 mA = 15 Ω, which is the same result.

▲Figure 4: STM32 datasheet
○ LED driver circuit using two high current ports
Some high brightness LEDs use more than 25mA, but they cannot be driven by a single high current port. For example, let's consider an LED with a rated current of 50mA. Assuming that we support 80% of the rated value, then 50mA x 0.8 = 40mA. This gives I = 40mA. Assuming the forward voltage Vf is 1.4V, the current-limiting resistor value (R) is, as before, (Vs -Vf)/I, so R = (3.0V-1.4V)/40mA = 40Ω. Since we use two NMOSs in parallel in this paper, the current through one NMOS is 40mA/2=20mA, which is the same as the previous design, so the ON resistance is 65Ω. The combined resistance of the two NMOSs is 65Ω/2=32.5Ω. The resistance when connected in series is 7.5Ω, which is obtained by subtracting 32.5Ω from R=40Ω. When these two GPIOs output Low at the same time, the LED turns on, and when they output High, it turns off. So the two high current port GPIOs can drive 50mA LEDs.

▲Figure 5: Example of LED driver circuit (using 2 MCU GPIOs)
○ Notes
(1) Comply with absolute maximum ratings
The IVDD parameter is included in the STM32 absolute maximum power values table (Figure 4(b)) and was used in the previous example. This parameter is the maximum current that can pass through the MCU power terminals. From the table, we can see that the value is 150mA. If the high current port is used to drive multiple LEDs simultaneously, the total current must not exceed this value. Currents exceeding this value can damage the MCU or cause latch-up.
(2) Using PMOS
In this paper, NMOS is used as a switch, but PMOS can be used if the MCU provides PMOS high-current ports. The calculation method is the same; VDD-VOH and IOH are used to obtain PMOS ON resistance.
(3) Actual circuit design
The parameter values we used in this paper are just examples. When designing an actual circuit, you should use the relevant datasheet and user manual to determine the characteristics of the LED and MCU GPIO. Since there are various types of LEDs and MCU GPIOs, if you do not use the appropriate values, the MCU or LED may fail.
본 기사에 대한 정정·반론·추후보도 청구는 보도 청구 안내를, 그간 게재된 보도문은 정정·반론보도 모아보기를 참고해 주세요.

.png)













