Summary of Microcontroller Knowledge

Publisher:平安守护Latest update time:2018-12-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

①RST reset circuit


MCU 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. 


Write the picture description here


③ 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.)


Control function of transistor 
Transistor realizes voltage conversion (5V controls 12V) 
Transistor driving function

④ 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.


Write the picture description here


⑩. 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 


Write the picture description here


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.


Write the picture description here



Note that the NA or NC pin indicates an empty pin.

Reference address:Summary of Microcontroller Knowledge

Previous article:I2C communication timing problem of 89 and 12 microcontrollers
Next article:Detailed steps for debugging delay time of keil software

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号