ARM bare metal programming learning first lesson of hardware knowledge LED principle diagram 01

1 Overview

For many programming languages, the first program to get started is to successfully output the "Hello, World" program, and the first "Hello, World" program for ARM bare metal programming isTurn on the LED light.
Therefore, the first lesson for learning ARM bare metal programming is to learn LED first and successfully light the LED light. If you want to successfully light the LED lights, you need to do the following things:

  • The first step is to look at the schematic diagram of the LED and determine the pin that controls the LED
  • The second step is to look at the ARM master chip manual to determine how to set and control the LED pins
  • The third step is to write the LED program

2. LED schematic

LED is the abbreviation of Light Emitting Diode, which means light-emitting diode.
There are many types of LEDs. According to the packaging method, they can be divided into pin LEDs and patch LEDs.

2.1 Circuit diagram symbols of diodes

A diode is a two-electrode electronic component with asymmetric conductivity.
An ideal diode has infinite resistance between its two electrodes when it conducts in the forward direction ("current from + to -"), and when it conducts in the reverse direction ("current from-to +"), it has infinite resistance, that is, the current is only Allow a single direction to flow through the diode ("current from + to -").
Insert picture description here

2.2 Circuit diagram symbols of light-emitting diodes

Light-emitting diodes are a type of semiconductor diodes that can convert electrical energy into light energy. Like ordinary diodes, light-emitting diodes are composed of a PN junction and also have unidirectional conductivity.
Insert picture description here

2.3 Diode circuit diagram

In order for the diode to conduct current, the positive pole of the power supply must be connected to the P pole of the diode, and the negative pole of the power supply must be connected to the N pole of the diode.
For light-emitting diodes (LEDs), a 3.3V voltage is generally required. The current calculation formula is I = V/R. Because the resistance of the diode is very small when the diode is forward conductive, it is necessary to connect a LED in series to avoid burning the LED. Resistance to reduce the current flowing through the LED.
Insert picture description here

2.4 Evolution from LED circuit diagram to LED schematic diagram

Use the main control chip to control the on and off of the LED lights.

2.4.1 The main control chip pin is connected to the positive pole of the LED

  • The pin of the main control chip is connected to the P pole of the LED, and the N pole of the LED is grounded.
  • When the main control chip outputs 3.3V voltage, the LED light is lit.
  • When the main control chip outputs 0V voltage, the LED light is turned off.
    Insert picture description here

2.4.2 The main control chip pin is connected to the negative pole of the LED

  • The pin of the main control chip is connected to the N pole of the LED, and the P pole of the LED is connected to a 3.3V power supply.
  • When the main control chip outputs 0V voltage, the LED light is lit.
  • When the main control chip outputs 3.3V voltage, the LED light is turned off.
    Insert picture description here

2.4.3 Some chip pins output low voltage

Some main chips have weak driving ability (for example, the purpose is to have a longer standby), and the pin can only output a small voltage such as 1.2V, which is not enough to drive the LED and cannot satisfy the control of the LED. In order to enable these weaker main control chips to control the LED, it can be realized with the help of a triode.


The diode is composed of one PN structure, and the triode is composed of two PN structures, and the shared electrode becomes the base of the triode.
The working principle of the triode:

  • The triode is a current amplifier device, with three poles, called collector C, base B, and emitter E.
  • The triode can be divided into PNP type triode and NPN type triode
    Insert picture description here

Take NPN transistor as an example:

  • The current flowing from the base b to the emitter E is called the base current Ib; the current flowing from the collector c to the emitter e is called the collector current Ic.
  • The directions of these two currents are both flowing out of the emitter e, so an arrow is used on the emitter E to indicate the direction of the current.
  • The amplification function of the triode is: the collector c current is controlled by the base B current, and a small change in the base current will cause a large change in the collector current, and the change satisfies a certain proportional relationship (change in collector current The amount is β times the amount of change in the base current, and β is a number greater than 1.)
  • When the base b outputs 0V, there is no conduction between be, so there is no conduction between ce.
  • When the base b outputs, for example, 1.2V, the be is turned on, so the ce is also turned on.

For NPN transistors, the main control chip is connected to the base. When the main control chip outputs 0V, the transistor is non-conducting; when the main control chip outputs 1.2V, for example, the triode is conducting.

For PNP type transistors, the main control chip is connected to the base. When the main control chip outputs 0V, the transistor is conductive; when the main control chip outputs 1.2V, for example, the transistor is non-conductive.

2.4.3.1 The main control chip controls the LED through a triode

When using a transistor to control LED lights, we don’t care how much volts the GPIO pin of the main control chip outputs, we only consider whether it outputs logic high level 1 or logic low level 0; for NPN transistors, when the main control chip outputs logic When the high level is 1, the LED is turned on, and the LED light is turned off when the main control chip outputs a logic low level of 0.
Insert picture description here

2.5 Other diodes

Insert picture description here

2.5.1 Zener diode

2.5.2 Tunnel Diode

2.5.3 Photodiode

2.5.4 Varactor diode

2.5.5 Schottky diode

2.5.6 Thyristor rectifier

Guess you like

Origin blog.csdn.net/wzc18743083828/article/details/111599900