Learning about microcontrollers is a long and somewhat painful process. Especially for beginners, it is difficult to form a systematic learning framework when various types of knowledge are incomplete in the early stages. This article aims to provide a thought process and list some essential foundational knowledge before getting into microcontrollers.
1. There are only two levels in digital circuits: high and low. The microcontroller is defined as TTL level: high +5V and low 0V.
2. RS232 level: the serial port of the computer. High -12V and low +12V. Therefore, a level conversion chip is needed for communication between the computer and the microcontroller.
3. Base conversion and logical, arithmetic operations.
4. It’s best to have a basic understanding of C language.
5. 80C51: The 80C51 is a typical variety in the MCS-51 series; other manufacturers develop CMOS microcontroller products based on the 8051 core, collectively referred to as the 80C51 series.
6. A bus (BUS) is a common channel for transmitting information between various components of a computer. There are two types of buses in a microcomputer: internal bus and external bus. The internal bus refers to the connections within the CPU. The external bus refers to the connections between the CPU and other components. There are three types of external buses: data bus (DB), address bus (AB), and control bus (CB).
7. CPU: Composed of arithmetic and control logic, it also includes an interrupt system and some external special function registers; RAM: Used to store read/write data, such as intermediate results of calculations, final results, and data to be displayed; ROM: Used to store programs, some original data, and tables; I/O ports: Four 8-bit parallel I/O ports that can be used for both input and output; T/C: Two timers/counters that can work in either timer mode or counter mode;
8. An interrupt control system with five interrupt sources: a full-duplex UART (Universal Asynchronous Receiver Transmitter) serial I/O port for serial communication between microcontrollers or between a microcontroller and a microcomputer; an on-chip oscillator and clock generation circuit, with an external quartz crystal and trimmer capacitor required. The maximum oscillation frequency depends on the microcontroller model and performance.
9. Included header files (can be viewed in the INC directory under the installation path)
Commonly includes: reg51.h, reg52.h, math.h, ctype.h, stdio.h, stdlib.h, absacc.h
Commonly used: reg51.h, reg52.h
(Defines special function registers and bit registers);
math.h (defines commonly used mathematical operations);
10. The format of the interrupt service routine
function_name() interrupt n using m
{ function implementation… }
11. I/O port definition
sbit beep = P2^3;
12. Basic timing of the microcontroller
Machine cycle and instruction cycle.
Oscillation cycle:Also known as the clock cycle, it refers to the period of the oscillation source providing clock pulse signals to the microcontroller, which is 11.0592MHZ on the TX experimental board.
State cycle:Each state cycle is twice the clock cycle, obtained by dividing the oscillation cycle by two.
Machine cycle:A machine cycle consists of 6 state cycles S1~S6, which is 12 clock cycles. Within one machine cycle, the CPU can complete an independent operation.
Instruction cycle:It refers to the total time required for the CPU to complete an operation. The execution time of each instruction consists of one or several machine cycles. In the MCS-51 system, there are single-cycle instructions, double-cycle instructions, and four-cycle instructions.
The above 12 knowledge points are some key concepts that must be understood in advance during the introductory stage of microcontrollers. After mastering these points, getting started with microcontrollers will not be so difficult, and you will surely grasp microcontroller design skills faster than those who are unaware of these points.