Introduction to microcontroller
1.What is a microcontroller
The microcontroller is an integrated circuit chip that uses very large scale integrated circuit technology to combine a central processing unit (CPU) with data processing capabilities, random access memory RAM, read-only memory ROM, various I/O ports and interrupt systems, timers/counters A small but complete computer system is formed by integrating functions such as display driver circuits, pulse width modulation circuits, analog multiplexers, A/D converters and other circuits on a silicon chip.
The structure block diagram of the microcontroller is as follows:
2. What can the microcontroller do?
From as small as toy cars and electronic watches to as large as spacecraft and robots, whether it is data collection, industrial control or intelligent instrumentation and communication equipment, microcontrollers are everywhere. Its main application areas are as follows: (1) Application in mechatronics. The combination of single-chip microcomputer and traditional mechanical products simplifies the structure of traditional mechanical products and makes the control more intelligent, transforming traditional products into a new generation of mechatronics products. This is the direction of the development of the machinery industry. (2) Application in monitoring system. The application of single-chip microcomputer in instrumentation equipment promotes the development of instruments and meters in the direction of digitalization, intelligence, multi-function and comprehensiveness. The software programming technology of single-chip microcomputer has solved long-term problems such as error correction and linearization processing in measuring instruments. (3) Application in measurement and control systems. Microcontrollers can be used in various industrial control systems, adaptive control systems, data acquisition systems, etc. For example, industrial boiler control, motor control, vehicle detection system, water gate automatic control, CNC machine tools and military weapons and equipment, etc. (4) Application in intelligent interface. Computer systems, especially larger industrial measurement and control systems, use single-chip computers for interface control and management. The single-chip computer and the host work in parallel, which can greatly improve the running speed of the system.
3. What microcontroller should a novice learn?
Novices recommend the 51 series microcontroller. There are many learning materials related to this series of microcontrollers, and they are relatively easy to find online. The 51 series of microcontrollers has a relatively large market share and can be found in many products. At the same time, the 51 series microcontroller is also the basis for learning high-end MCUs such as ARM, DSP, and FPGA.
4. Microcontroller hardware structure
(1) Three major internal resources of the microcontroller
Flash - program storage space. Early microcontrollers used OTPROM: In early microcontrollers, OTPROM (One Time Programmable Read-Only Memory) was mainly used to store the program of the microcontroller. The program could only be written to once. With the development of technology, Flash has become the program memory of most microcontrollers due to its repeated erasing, large capacity and low cost. For microcontrollers, the biggest significance of Flash is that data will not be lost after power failure.
RAM - data storage space: RAM is used to store data generated and needed during the running of the program. The data is lost after the power is turned off. Its advantages are, first, that it is very fast to read and write, and second, that it can theoretically be written infinitely, that is, it has an unlimited lifespan, and it will not break no matter how the program runs and reads and writes.
SFR - special function register: The microcontroller has many functions, and each function corresponds to one or more SFRs. We realize the various functions of the microcontroller by writing programs to control the reading and writing of SFRs.
(2) Label information
The following introduction takes the STC89C52RC microcontroller as an example:
All labels on the chip are STC89C52RC, 40I-PDIP40, and 1428HBS967.C90C. The label explanation is as follows.
STC - chip production company, STC means Hongjing Company. Common prefixes include AT, P, W, SST, etc. Among them, AT represents Atmel Company, P represents Philips Company, W represents Winbond Company, and SST represents SST Company.
8 - This chip is an 8051 core chip.
9——The chip contains Flash EEPROM memory. Others, such as 0 in 80C51, indicates that the internal mask memory (Mask ROM) is included, and 7 in 87C51 indicates that the internal UV erasable ROM (EPROM) is included.
C——This device is a CMOS product. Others include 89LE52, 89LV52, and 89LS52. The LE, LV, and LS represent low-voltage products (usually their operating voltage is 3.3V). The S in 89S52 represents that this series of chips has an ISP online programming function.
5 - Fixed.
2——The size of the chip’s internal program storage space. 1 is 4 KB, 2 is 8 KB, and 3 is 12 KB. That is, multiplying this number by 4 KB is the size of the internal program storage space of the chip. The larger the space, the more program code can be loaded. Of course, the larger the space, the higher the price of the chip. Therefore, when choosing a chip, we must make a reasonable choice based on our needs, as long as it is enough. The size of this space is not related to other performance of the microcontroller and does not affect the functions of the microcontroller.
RC——The internal RAM of STC microcontroller is 512B, and RD+ means the internal RAM is 1280B.
40——The external crystal oscillator of the chip can be connected up to 40 MHz. Like Atmel's microcontroller, this value is generally 24, which means that the highest external crystal oscillator is 24 MHz.
I——Product level. I means industrial grade, the temperature range is -40~85℃. Others such as C means commercial grade, the temperature range is 0~70℃; A means automotive grade, the temperature range is −40~125℃; M means military grade, the temperature range is −55~150℃.
PDIP——Product package model. PDIP is dual in-line. Others such as PLCC is a plastic chip package with leads; QFP is a plastic square flat package; PFP is a plastic flat component package; PGA is a pin grid array package; BGA is a ball grid array package.
40——Number of pins.
1428 - The production date of this batch of chips is the 28th week of 2014.
(3) Introduction to pin functions
Note: The first pin of the chip is usually marked on the chip. Some are a small circular pit or a dot, and some are the marks next to the starting pin of the entire chip. After pin 1 is found, the serial numbers of other pins are numbered starting from pin 1 in the top view and increasing in counterclockwise order.
The pins of microcontrollers can be roughly divided into four categories:
① Power pins: VCC, GND.
② Clock pins: XTAL1, XTAL2.
③ Control pins: RST, PSEN, ALE/PROG, EA/VPP.
④ I/O pins: 4 8-bit parallel I/O ports P0, P1, P2, P3, 32 pins in total.
VCC (pin 40): The positive pole of the microcontroller power supply. The power supply voltage of different types of microcontrollers will be different, usually +5V, if it is low voltage, it is +3.3V. Before use, please check the data sheet corresponding to the microcontroller.
GND (pin 20): negative pole of microcontroller power supply, ground terminal.
XTAL1 (pin 19), XTAL2 (pin 18): clock circuit pins. XTAL1 is connected to one end of the external crystal oscillator and the trimming capacitor. On-chip, it is the input end of the oscillator inverting amplifier and clock generator. If an external clock is used, this pin must be connected to ground. XTAL2 is connected to the other end of the external crystal oscillator and the trimmer capacitor. On-chip, it is the output end of the oscillator inverting amplifier. If an external clock is used, this pin is connected to the input of the external clock.
RST (pin 9): MCU reset pin. A high level that lasts for more than two machine cycles causes a system reset. This means that the program will run from scratch.
PSEN (pin 29): External program memory strobe signal output pin. When reading external ROM, PSEN is active at low level to realize the reading operation of external ROM unit. With the development of technology, the internal storage ROM of microcontrollers has become larger and larger, and it can already meet the needs of use, and basically no one anymore expands the external ROM. When designing the circuit, this pin is generally left floating and not used.
① When reading the internal ROM, PSEN does not operate;
② When reading external ROM, it will operate twice in each machine cycle;
③ When reading from external RAM, two PSEN pulses will be skipped and will not be output;
④ When connecting to an external ROM, connect it to the OE pin of the ROM.
ALE/ PROG ( 30 脚):具有两种功能,可以作为地址锁存使能端和编程脉冲输入端。当作为地址锁存使能端时为 ALE。当单片机访问外部程序存储器时, ALE 的负跳变将低8 位地址打入锁存。当访问外部数据存储器时,例如执行 MOVX 类指令, ALE 引脚会跳过一个脉冲。当单片机没有访问外部程序存储器时, ALE 引脚将有一个 1/6 振荡频率的正脉冲信号输出,该信号可以用于外部计数或电路其他部分的时钟信号。当作为编程脉冲输入端时为PROG ,在进行程序下载时使用。现在很多单片机在烧录程序时已不需要编程脉冲引脚往内部写程序。比如我们使用的 STC 单片机,它是通过串行口烧录的,使用更为简便。现在的单片机已带有丰富的 RAM 和更为简便的程序烧录方式,因此 ALE/ PROG 这个引脚已很少用到,我们了解即可。在设计电路时一般悬空,不作使用。
EA /VPP( 31 脚):具有两种功能。EA :程序存储器选择。 EA =1 时,单片机执行内部程序存储器的程序,当扩展有外部程序存储器时,在执行完内部程序存储器的部分程序后,自动执行外部程序存储器的程序。EA =0,单片机执行外部程序存储器的程序。
VPP:在内部程序存储器擦除和写入时提供编程脉冲。现在的单片机一般内部的 ROM 已经足够大,能满足我们的程序存储需求,所以 VPP 的功能一般不用。因此一般在设计电路时,此引脚始终给它接上高电平即可。
I/O 引脚 : STC89C52 共有 4 个 8 位并行 I/O 端口,分别为 P0、 P1、P2、 P3 口,共 32 个引脚。
P0 口( 39 脚~32 脚): P0 口是一个 8 位漏极开路的双向端口,分别为P0.0~P0.7 口,可独立控制。 P0 口在作为低 8 位地址/数据总线使用时不需接上拉电阻;作为一般的 I/O 口使用时,由于内部没有上拉电阻,在使用时需要接上拉电阻。一般选用 10kΩ 电阻作为上拉电阻。
P1 口( 1 脚~8 脚): P1 口是一个带上拉电阻的 8 位准双向端口,分别为 P1.0~P1.7 口,可独立控制,也可做输入或输出口使用。
P2 口( 21 脚~28 脚): P2 口是一个带上拉电阻的 8 位准双向端口, 分别为 P2.0~P2.7 口,可独立控制,可做输入或输出口使用,功能和 P1 口相似。
P3 口( 10 脚~17 脚): P3 口是一个带上拉电阻的 8 位准双向端口, 分别为 P3.0~P3.7 口,可独立控制。是一个双用途端口,可做输入或输出口使用,功能和 P1 口相似。它还具有第二功能,具体如表所示。
Previous article:The internal structure and functions of 51 microcontroller
Next article:Analysis of 100 Examples of 51 Microcontroller C Language Programs (4) Peripherals
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- How to deduce normalized parameters from transfer functions and then design filters
- Output swings to GND Single supply, low side, unidirectional current circuit
- About the problem of converting schematic diagram to PCB when designing RF PCB circuit
- QSPI read, write and erase flash
- Msp430f149 external interrupt problem
- Application of DSP Digital Signal Processor in Coriolis Mass Flow Meter
- 【CH579M-R1】+OTA principle and source code analysis
- NEC begins testing flying cars
- The function and usage of the segmented storage function of the digital oscilloscope
- Switching power supply problem