The 51 series is the most widely used single-chip microcomputer. Due to the reasonable hardware structure of the product, the specification of the instruction system, and the “long” production history, it has the advantage of being preconceived. There are many well-known chip companies in the world who have purchased the core patented technology of the 51 chip and expanded the performance based on it, so that the chip has been further improved and a huge system has been formed. The world of single-chip microcomputers is buzzing with excitement.

1. Analysis of the advantages and disadvantages of 51 series microcontrollers

The 51 series is the most widely used single-chip microcomputer. Due to the reasonable hardware structure of the product, the specification of the instruction system, and the “long” production history, it has the advantage of being preconceived. There are many well-known chip companies in the world who have purchased the core patented technology of the 51 chip and expanded the performance based on it, so that the chip has been further improved and a huge system has been formed. The world of single-chip microcomputers is buzzing with excitement.

One of the advantages of the 51 series is that it has a complete bitwise operating system from the internal hardware to the software, called a bit processor, or Boolean processor. Its objects are not words or bytes but bits. It can not only process a certain bit of some special function registers in the chip, such as transfer, set, clear, test, etc., but also perform bit logic operations. Its functions are very complete and easy to use. Although other types of microcontrollers also have bit processing functions, it is rare to be able to perform bit logic operations. The 51 series has also developed a dual-function address range in the on-chip RAM range, 16 bytes, and the unit address is 20H~2FH. It can be used for both byte processing and bit processing (when used for bit processing, combined 128 bits, the corresponding bit address is OOH ~ 7FH), the use is extremely flexible. This function undoubtedly provides great convenience to the user, because a relatively complex program will encounter many branches during the running process, so many flag bits need to be established. During the running process, the relevant flag bits need to be set. Bits, clears, or checks to determine the direction in which the program is running. To implement this processing (including all the previous bit functions), only one bit manipulation instruction is needed.

Another advantage of the 51 series is the multiply and divide instructions, which also brings convenience to programming. For the division instruction of eight bits divided by eight bits, the quotient is eight bits, and the precision is not enough, so it is not used much. And the multiplication instruction of eight bits by eight bits, its product is sixteen bits, the precision can still meet the requirements, and it is used more. When doing multiplication, only one instruction is needed. Many eight-bit single-chip microcomputers do not have the multiplication function. When doing multiplication, a subroutine call must be compiled, which is very inconvenient.

The setting and use of the I/O pins of the 51 series is very simple, but there is no output capability at high level, which can be described as both advantages and disadvantages. Therefore, other series of microcontrollers (such as PIC series, AVR series, etc.) have improved the I/O port and added a direction register to determine input or output, but the use has also become complicated.

At the same time, the original 51 series also has many points worth improving, such as the running speed is too slow. When the crystal oscillator frequency is 12MHz, the machine cycle reaches 1μs, which obviously cannot meet the needs of modern high-speed operation. The product models produced by Winbond are W77 series and W78 series, and the W78 series is fully compatible with the AT89C series. The W77 series is an enhanced type, which improves the original 8051 timing. Each machine cycle is changed from 12 clock cycles to 4 cycles, which triples the speed. At the same time, the crystal frequency can reach up to 40MHz. W77 series also added watchdog WatchDog, two sets of uART, two sets of DVTR data pointer, ISP and other functions.

2. Analysis of the advantages and disadvantages of PIC microcontrollers

The PIC microcontroller CPU adopts the RISC structure, with 33, 35, and 58 instructions respectively (depending on the level of the microcontroller), which is a simplified instruction set. The 51 series has 111 instructions, and the AVR microcontroller has 118 instructions, which are more complicated than the former. Using Haryard dual bus structure, the running speed is fast (the instruction cycle is about 160-200nS), it can make the access of the program memory and the access of the data memory processed in parallel. This instruction pipeline structure completes two parts of work in one cycle, one is To execute the instruction, the second is to fetch the next instruction from the program memory, so that in general, each instruction only needs one cycle (except for a few), which is also one of the reasons for efficient operation. In addition, it also has the characteristics of low operating voltage, low power consumption, and strong driving ability.

The I/O port of the PIC series microcontroller is bidirectional, and its output circuit is a CMOS complementary push-pull output circuit. The I/O pin has added a direction register for setting the input or output state, thus solving the state of both input and output when the I/O pin of the 51 series is at a high level. When it is set to 1, it is an input state, and regardless of whether the pin is at a high level or a low level, it is in a high-impedance state to the outside world; when it is set to 0, it is an output state, and no matter what level the pin is, it is in a low-impedance state. , There is considerable driving ability, the low-level suction current can reach 25mA, and the high-level output current can reach 20mA. Compared with the 51 series, this is a great advantage, it can directly drive the digital tube Display and the external circuit is simple. Its A/D is 10 bits, which can meet the precision requirements. With online debugging and programming functions.

The special registers of this series of microcontrollers) are not concentrated in a fixed address range (80~FFH) like the 51 series, but are scattered in four address ranges, namely memory bank 0 (Bank0: 00-7FH), Bank 1 (Bank1: 80-FFH), Bank 2 (Bank2: 100-17FH), Bank 3 (Bank3: 180-1FFH). Only 5 special registers PCL, STATUS, FSR, PCLATH, INTCON appear simultaneously in 4 memory bodies. In the programming process, it is necessary to deal with the special register, and the corresponding memory bank must be selected repeatedly, that is, the 6th bit (RPl) and the 5th bit (RPO) of the status register STATUS are set or cleared. This brings some trouble to programming. For the above single-chip microcomputer, its bit instruction operation is usually limited to the storage bank 0 interval (00 ~ 7FH). Data transfer and logical operations are basically carried out through the working register w (equivalent to the accumulator A of the 5l series), and the 51 series can also be directly transferred between each other through registers (such as: MOV30H, 20H; register 20H The content of the MCU is directly transferred to the register 30H), so the bottleneck of the PIC microcontroller is more serious than that of the 51 series, which is very felt in programming.

In general, PIC microcontrollers should have three main characteristics:

(1) Bus structure: The bus structure of the MCS-51 microcontroller is a von Neumann type. The computer fetches instructions and data in the same storage space, and the two cannot be performed at the same time; while the bus structure of the PIC microcontroller is a Harvard structure. The data space is completely separated, one is for instructions and the other is for data. Since the program and data can be accessed at the same time, the data throughput rate is improved. Just because the Harvard dual bus structure is used in the PIC microcontroller, the difference from the common microcontroller is that the program and data buses can use different widths. The data bus is 8-bit, but the instruction bus bits are 12, 14, and 16 bits respectively.

(2) Pipeline structure: The instruction fetch and execution of the MCS-51 single-chip microcomputer adopts a single-instruction pipeline structure, that is, one instruction is fetched, and then the next instruction is fetched after execution; while the PIC’s instruction fetch and execution adopts a dual-instruction pipeline structure. When an instruction is executed, the next instruction is allowed to be fetched at the same time, thus realizing a single-cycle instruction.

(3) Register group: All registers of PIC microcontroller, including I/O ports, timers and program counters, are in the form of RAM, and only one instruction cycle is needed to complete access and operation; while MCS-51 microcontroller requires It takes two or more cycles to change the contents of the register.

3. Analysis of the advantages and disadvantages of AVR monolithic

Detailed explanation of pic microcontroller and AVR, 51 series microcontroller

The remarkable features of AVR microcontroller are high performance, high speed and low power consumption. It cancels the machine cycle, takes the clock cycle as the instruction cycle, and implements the pipeline operation. AVR microcontroller instructions are in word units, and most of the instructions are single-cycle instructions. The single cycle can execute the function of this instruction and complete the reading of the next instruction at the same time. There are a total of 32 general-purpose registers (RO-R31), and the first 16 registers (R0-R15) cannot directly deal with immediate data, so the versatility is reduced. In the 5l series, all its general-purpose registers (address 00-7FH) can directly deal with immediate data, which is obviously better than the former.

The AVR series does not have a structure similar to the accumulator A. It mainly realizes the function of A through the R16~R31 registers. In AVR, there is no data pointer DPTR like 5l series, but three 16-bit registers of X (composed of R26, R27), Y (composed of R28, .R29), z (composed of R30, R31). Complete the function of the data pointer (equivalent to three sets of DPTR), and can also perform post-increment or pre-decrement operations.

In the 51 series, all logical operations must be performed in A; while AVR can be performed between any two registers, eliminating the tossing back and forth in A, which is stronger than the 51 series.

The special registers of AVR are concentrated in the address range of $00~$3F. There is no need to perform the process of selecting the memory bank first like PIC. It is more convenient to use than PIC. The address range of AVR’s on-chip RAM is $0060~$00DF (AT90S23131) and $0060~$025F (AT90S85l5, AT90S8535), they occupy the address of data space, these on-chip RAM are only used to store data, usually not It has the function of general-purpose register. When the program is complicated, the general-purpose registers R0-R31 are not enough; while the general-purpose registers of the 51 series are up to 128 (4 times that of the AVR), there is no such feeling when programming.

The I/O pin of AVR is similar to PIC. It also has a direction register used to control input or output. In the output state, the high-level output current is about 10mA, and the low-level current sinks 20mA. Not as good as PIC, but better than 51 series.

On the whole, AVR has a series of advantages compared with 51 and PIC microcontrollers, which are mainly reflected in these aspects in popular terms:

(1) AVR runs the fastest under the same system clock;

(2) The FLASH and EEPROM accumulators of all AVR microcontrollers can be programmed repeatedly, support online programming (programming) in ISP, and the entry fee is very low;

(3) The on-chip integrated RC oscillator with multiple frequencies, power-on automatic reset, watchdog, startup delay and other functions make the circuit design very simple;

(4) Each IO port can output a strong high and low level when it is used as an output, and the IO port can be high impedance or with a pull-up resistor when it is used as an input;

(5) The chip has rich and practical resources, such as AD analog-digital device, DA digital-analog device, rich interrupt sources, SPI, USART, TWI communication port, PWM, etc.;

(6) The advanced data encryption technology is adopted in the chip, which greatly improves the difficulty of cracking;

(7) The on-chip FLASH space is large and there are many varieties. The few pins are 8 pins, and the more pins are 64 pins and other packages.

(8) The pins of some chips are compatible with 51 series, and it is easy to replace, such as ATtiny2313 is compatible with AT89C2051, ATmega8515/162 is compatible with AT89S51, etc.

Fourth, the choice of microcontroller.

Various microcontrollers have their own advantages and disadvantages, and should be selected according to needs. The principles of selecting a microcontroller are as follows:

1. Basic parameters of the microcontroller such as speed, program memory capacity, number of I/O pins

2. Enhanced functions of microcontroller, such as watchdog, dual pointer, dual serial port, RTC (real time clock), EEPROM, extended RAM, CAN interface, I2C interface, SPI interface, USB interface.

3. Compared with OTP (One Time Programmable), Flash is the best.

4. Package DIP (dual in-line), PLCC (PLCC has a corresponding socket) or SMD. DIP packaging may be a little more convenient when doing experiments.

5. Operating temperature range, industrial or commercial. If you design outdoor products, you must choose industrial grade.

6. Power consumption. For example, when designing a parallel port dongle, the signal line can only provide a few mA. The PIC is used because of low power consumption. Later, the MSP430 is also good.

7. Operating voltage range. For example, the design of a TV remote control, powered by 2 dry batteries, should be able to work within the voltage range of 1.8-3.6V at least.

8. The supply channels are smooth. Can apply for samples, small batches are available in stock. It’s better to be like Standard 51, you can buy it at any counter in Zhongfa (I’m in Beijing)

9. Low prices.

10. There are service providers, such as Zhou Ligong’s promotion of Philips, and Ssangyong’s promotion of AVR, which provide a lot of useful technical support, at least there is a place to buy programmers.

11. The price of the programmer is low. If it is an ICP (programming the microcontroller on the programmer), can the existing programmer be used? If it is a surface mount package, it is also very expensive to buy an adapter. At least one adapter is required. Two hundreds. Whether ISP (in-system programming, that is, soldering the chip to the board first and then programming through the reserved ISP interface), the general ISP programmer is cheaper about one or two hundred yuan or even tens of yuan.

12. Emulators are cheap. For FLASH type microcontrollers, an emulator is not necessary. But for OTP (One Time Programmable) type microcontrollers, an emulator must be purchased or leased.

13. The MCU assembly language is familiar to oneself and can support C language. The programming environment should be as easy to use as keil and still free.

14. The website is fast and informative. Including chip manual, application guide, design scheme, sample program. It is best to have Chinese, like Atmel is good.

15. The confidentiality performance is good, check the blacklist on the professional decryption website, and then send an email to inquire about the decryption price.

16. Good anti-interference performance. I once changed the XXC52 to S52 and found that the anti-interference performance decreased, so I had to change it back.

17. Comprehensive consideration of putting together with other peripheral chips

The Links:   QM300HA24 B141XG08-V3