①RST reset circuit
51 MCU is reset at high level and works normally at low level
At the moment of power-on and when the button is pressed (the capacitor is equivalent to the wire), RST is at a high level.
When a key is pressed, a large current surge will occur, which will cause a large amount of electromagnetic interference locally. In order to reduce this interference, a current limiting resistor is added.
②About RAM and FLASH
The STC89C52RC series microcontroller has 512B of RAM and 8K of Flash (program storage space)
RAM is used to store variables. For example, if you define a bit, uint8, uint16, uint32, etc., these are all defined in RAM.
Although 512B RAM has the same name, it is different in physical structure and usage.
Following the old 8051 MCU, it is still called on-chip RAM and off-chip RAM. The so-called on-chip and off-chip refer to the inside and outside of the chip, but the chip expansion of the current MCU is basically internal, and there is no such thing as off-chip expansion RAM. But we still call it this way, just know it.
The on-chip RAM is divided into data and idata. Generally, the variables we define directly are directly in data. Data is directly addressed and has the fastest speed. The others are indirectly addressed through registers, and their speed is certainly not comparable.
The data range is from 0x00 to 0x7F in the chip, a total of 128 bytes
The idata range is from 0x80 to 0xFF in the chip, which is also 128B, but it is not used to store variables, and of course it is not expected that the program can access it. Its main purpose is to interrupt and call functions.
The off-chip RAM is divided into pdata and xdata as mentioned above, both of which are indirectly addressed through registers.
The addressing range of pdata is 0x00~0xFF, a total of 256B. The addressing speed is relatively faster than xdata.
The addressing range of xdata is 0x0000~0xFFFF at the end of the film, a total of 64K. The addressing range is the widest. If you want to use it, you must specially configure two byte registers DPTRH and DPTRL. The wide addressing range also means the slowest speed.
So, to sum it up: generally variables are stored in the data area. When data is not enough, look for the xdata area. Do not touch idata. Do not touch pdata unless it is absolutely necessary!!!
It seems that the high-byte extended 128RAM overlaps with the register address, but it does not overlap physically.
③ Transistor
The main uses are: drive and control
Characteristics of transistor: cut-off, saturation, and amplification.
(In digital electronics, the switching function of the transistor is mainly used, and the cutoff and saturation characteristics (with a β factor) are used. In its amplification characteristics are used.)
④ Addressing by byte code and addressing by word code
Addressing by byte encoding, 1M = 2^20B and 1B = 8bit, so 2^20B/1B = 2^20
The address that can be found is 1~2^20-1
Twenty buses are required
Addressing by word encoding, 1 word has 4 bytes, and the rest is the same as above, then 2^20/1 word = 2^20/4 bytes = 2^18
The address that can be found is 1~2^18-1
Requires 18 buses
By the way, in addition to this, there is one more thing to note, which is the difference between MB and M.
MB is a unit of capacity, megabyte
And M is a unit of quantity, megabytes
The LED voltage drop is 2V, and the working current is 1~20mA. Generally, the change within 1~5mA can be directly reflected in the brightness of the light. If it exceeds 5mA, it will not be so obvious. Therefore, the selected series resistor can be 150 ohms~3K.
⑤Three-eight decoder quickly remembers the corresponding, in fact, the three on the left can be seen as the binary number, and the corresponding right side is 0
For example, if A2 A1 A0 on the left is 0 0 0, then the corresponding values of Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 on the right are 0 1 1 1 1 1 1 1
⑥ About IO port
The IO port has four states: quasi-bidirectional, open drain, strong push-pull, and high impedance
The most commonly used ones are quasi-bidirectional and open-drain. The main difference between the two is that the open-drain has no internal pull-up resistor. The P0 of the 51 microcontroller is open-drain by default, while the other ports are quasi-bidirectional IO. For P0, remember to add an external pull-up resistor when you DIY a small circuit!
Pay special attention to quasi-bidirectional IO: An important knowledge of 51 microcontroller is that if you want to correctly read the state of the external signal, you must first ensure that it is a high level.
⑦Pull-up resistor and pull-down resistor
The main applications of pull-up resistors are:
OC gate is open drain output
When the current output needs to be increased, adding a pull-up is equivalent to connecting a resistor in parallel.
It can also play a role in current limiting, such as 5V to 12V system
Resistant to EMI (Electromagnetic Interference)
sbit
sbit is used to define a bit of a single-byte bit-addressable object. "Single-byte bit-addressable" includes bit-addressable special function registers and 16 bytes of bit-addressable area in RAM.
The bata keyword can locate variables in the internal bit-addressable RAM.
For example:
char bdata bittest;
sbit RIbit = bittest^0;
sbit TIbit = bittest^1;
sbit P1_0 = P1^0;
⑧ Summary of pulling IO port to high level
Usually we will encounter the situation that the IO port cannot be pulled high in the common quasi-bidirectional IO port. What should we do at this time?
Try all the IO port states. Some are special. For example, if an IO port is connected to an external pull-up resistor, the drain must be opened to pull it to a high level.
Is the microcontroller running too fast? You can delay it appropriately.
⑨About relays
Module interface:
1. DC+: Connect to the positive pole of the power supply (the voltage is based on the relay requirements, with 5V, 9V, 12V and 24V options)
2. DC-: Connect to the negative pole of the power supply
3. IN: can control the relay to be closed at high or low level
Relay output:
1. NO: Relay normally open interface, the relay is suspended before it is energized, and short-circuited with COM after it is energized.
2. COM: relay common interface
3. NC: Relay normally closed interface, short-circuited with COM before the relay is energized, and left floating after energization
High and low level trigger *Selection terminal: *
1. When the jumper is shorted to LOW, it is triggered at low level;
2. When the jumper is shorted to high, it is a high level trigger.
⑩. About the pinout of DS18B20
In short, when the plane is facing you, the three pins are GND, VOUT and VCC.
The picture above shows everything
11. DHT11
DHT11 is a temperature and humidity composite sensor with a calibrated single bus digital signal output. It includes a resistive humidity sensor and an NTC temperature measuring element, and is connected to a high-performance 8-bit microcontroller. DHT11 is a civilian device, and the measured value is only accurate to the unit place, that is, there is no data after the decimal point. If it is to be used in industrial products or more precise applications, it is recommended to use DHT21 or SHT10.
Note that the NA or NC pin indicates an empty pin.
Previous article:I2C communication timing problem of 89 and 12 microcontrollers
Next article:Detailed steps for debugging delay time of keil software
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How ADI builds a bridge from the physical world to the digital world through product changes
- 【AT32F421 Review】+ CoreMark score
- Unboxing Review
- Supplementary information on the two disassembled isolators and detailed disassembly pictures
- MCU reset problem
- Please advise on PMOS high-side driver under wide voltage range!
- LIS2MDL array magnet displacement data acquisition for magnetic nail navigation AGV
- Domestic Bluetooth BLE chip
- EEWORLD University Hall----Digital Image Processing (MATLAB) Shandong University (Jiang Mingyan)
- [RT-Thread reading notes] First acquaintance