January 09, 2025

SCM minimum system composition and I/O output control program knowledge

SCM is a relatively strong technology, many beginners are often confused when learning SCM technology development, I do not know where to start. To this end, the author combines his own experience with the use of single-chip microcomputer for many years, specifically designed for the development of the Single-c machine and hardware kit required for the development of single-chip, and the combination of the suite carefully prepared the microcontroller from entry to the master series tutorial. Through the description of the principles of the SCM, circuit design, application development software tools, and the preparation of experimental examples, the reader is fully exposed to the SCM technology. The tutorial layout is light and deep, step by step, and the content strives to be complete, practical, and interesting. This will enable the reader to gradually increase the integrated software and hardware design level of the SCM in a relaxed and enjoyable learning process.

I. Contents

This lecture mainly introduces the implementation of the minimum system of the 51 series single-chip microcomputer and realizes the output control of the IO port of the single-chip microcomputer by programming. To light up the externally connected LED (Light Emitting Diode) as an example, briefly introduce the principle of the SCM and the composition of the minimum system, and use the simple C51 program design to describe the use of the compiler software Keil and download the Hex file to program the SCM.

Second, the principle of introduction

Before understanding the principle, let us first think about a problem. What is a microcontroller and what is the use of a microcontroller? This is an interesting question because no one can give a concept that is recognized by everyone. So what is a microcontroller? In general, a single-chip microcomputer, also known as a single chip microcontroller, integrates a CPU (Central Processing Unit), RAM (Data Memory), ROM (Program Memory), timers/counters, and various functions of I/O in a single chip. O (input/output) interface, etc. The basic functional components required by a computer, which can complete complex operations, logic control, communications and other functions. Here, we do not need to find a clear concept to resolve what is a single-chip microcomputer, especially when using C language to write the program, do not have much to understand the internal structure of the microcontroller and the operating principle. From an application point of view, start with a simple program, slowly familiarize yourself with and gradually deepen the master microcontroller.

After simply understanding what is a microcontroller, then we build the minimum system of the microcontroller. The minimum system of the microcontroller is the necessary part for the microcontroller to work properly and play its function. It can also be understood as the composition of the smallest component. The system that the one-chip computer can work. For 51 series microcontrollers, the minimum system should generally include: SCM, clock circuit, reset circuit, input/output devices (see Figure 1).

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 1 SCM minimum system block diagram

Third, the circuit detailed

Based on the above, the minimum system for the design of 51 series microcontrollers is shown in Figure 2.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 2 51 series microcontroller minimum system

The following is a detailed description of the circuit of each part of the minimum system microcontroller shown in Figure 2.

Clock circuit

Before designing the clock circuit, let us first understand the clock pins on the following 51-chip microcomputers:

XTAL1 (19 pin): Internal oscillator circuit input.

XTAL2 (18-pin): Internal oscillation circuit output of the chip.

XTAL1 and XTAL2 are independent input and output inverting amplifiers. They can be configured to use quartz oscillator's on-chip oscillator or the device is directly driven by an external clock. Figure 2 uses the internal clock mode, which uses the internal oscillator circuit. External timing components (a quartz crystal and two capacitors) are connected to the XTAL1 and XTAL2 pins. The internal oscillator can generate self-oscillation. In general, the crystal oscillator can be optionally between 1.2 and 12 MHz, and can even reach 24 MHz or higher, but the higher the frequency, the greater the power consumption. The 11.0592M quartz crystal used in this experimental kit. The size of the two capacitors in parallel with the crystal oscillator has a slight effect on the oscillation frequency, which can play a role in frequency fine-tuning. When a quartz crystal is used, the capacitance can be selected between 20 and 40 pF (30 pF in this experimental kit). When ceramic resonant devices are used, the capacitance should be appropriately increased, between 30 and 50 pF. A 33pF ceramic capacitor is usually sufficient.

It is also worth mentioning that if the reader himself is designing a printed circuit board (PCB) of the SCM system, the crystals and capacitors should be as close as possible to the SCM chip to reduce the parasitic capacitance of the leads and ensure reliable operation of the oscillator. To detect whether the crystal oscillator is started, you can use the oscilloscope to observe the very nice sine wave of the XTAL2 output, or you can use a multimeter to measure (drive the gear to the DC block, and then measure the effective value) between XTAL2 and ground. At the voltage, you can see a voltage of about 2V.

Reset circuit

In a microcontroller system, the reset circuit is critical. When the program runs away (runs abnormally) or crashes (stops operation), it needs to be reset.

When MCS-5l series microcontroller reset pin RST (pin 9) appears high for more than 2 machine cycles, the microcontroller performs a reset operation. If RST continues to be high, the microcontroller is in a cyclic reset state.

There are two basic forms of reset operation: power-on auto reset and switch reset. The reset circuit shown in Figure 2 includes both reset methods. At the moment of power-up, the voltage across the capacitor cannot be changed. At this time, the negative electrode of the capacitor is connected to RESET. The voltage is applied to the resistor. The input of RESET is high and the chip is reset. As the +5V Power Supply charges the capacitor, the voltage across the resistor gradually decreases. Finally, the voltage is approximately equal to zero and the chip operates normally. Parallel connection is a reset button at both ends of the capacitor. When the reset button is not pressed, the circuit achieves a power-on reset. After the chip works normally, the RST pin appears high level to achieve a manual reset effect by pressing the button. In general, as long as the RST pin is kept high for more than 10ms, the microcontroller can be effectively reset. The reset resistors and capacitors shown in the figure are classical values. The actual production can be replaced by resistors and capacitors of the same order of magnitude. The reader can also calculate the RC charging time or actual measurement in the working environment to ensure that the reset circuit of the microcontroller is reliable.

3. Function and connection of EA/VPP (31 feet)

The 51 Microcontroller EA/VPP (Pin 31) is a selection pin for internal and external program memory. When EA is held high, the microcontroller accesses internal program memory; when EA is held low, only external memory is accessed, regardless of whether or not there is internal program memory.

For most of today's MCUs, their internal program memory (usually flash) is very large, so basically no external program memory is needed, but the internal memory is used directly.

In this lab suite, the EA pin was connected to VCC and only the internal program memory was used. It must be noted that many beginners often leave the EA pin floating, resulting in abnormal program execution.

4. P0 port external pull-up resistor

The P0 port of the 51-chip microcomputer is an open-drain output with no internal pull-up resistor (see Figure 3). Therefore, when doing normal I/O output data, since V2 is turned off, the output stage is an open-drain circuit. To make the “1” signal (ie, high level) output normally, an external pull-up resistor must be connected.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Fig. 3 1-bit structure of P0 port

In addition, to avoid reading data errors during input, an external pull-up resistor is also required. Here's a brief explanation of the reason: In the input state, the signals read from the latch and the slave pins are generally the same, but there are exceptions. For example, when the low level is output from the internal bus, the latches Q = 0, Q = 1, the field effect transistor V1 is turned on, and the port line goes low. At this moment, no matter whether the external signal on the port line is low level or high level, the signal read from the pin to the MCU is low level, so the signal on the port pin cannot be read correctly. For another example, when the high level is output from the internal bus, the latch Q = 1, Q = 0, and the field effect transistor V1 is turned off. If the external pin signal is low, the signal read from the pin is different from the signal read from the latch. Therefore, when P0 is used as a general-purpose I/O interface input, write “1” to P0 before inputting data. At this time, the Q terminal of the latch is “0”, making the output stage have two field effects. The tubes V1 and V2 are all turned off and the pins are in a floating state for high impedance input.

To summarize, an external pull-up resistor is required to enable the P0 port to drive the NMOS circuit during output and to avoid reading data errors during input. In this lab suite, an additional 10K exclusion was used. In addition, on the input operation of port P0-P3, 51 MCU should write “1” to the latch in the circuit to avoid read errors, so that the FET is turned off to avoid the latch being "0". Interference with pin read-in status.

5. LED drive circuit

Careful readers may have found that in the smallest system, the connection of light emitting diodes (LEDs) is taken from the power supply to the anode of the diode and then through the 1K resistor to the I/O port of the microcontroller (see connection 1 in Figure 4). . Why is it so? First of all, we need to know the operating conditions of LEDs. Different LEDs have different rated voltages and rated currents. In general, the working voltage of red or green LED is 1.7V~2.4V, and the working voltage of blue or white LED is 2.7 ~ 4.2V, 3mm diameter LED operating current 2mA ~ 10mA. Red 3mm LEDs are used here. Second, when the I/O port of a 51-chip microcomputer (such as the STC89C52 microcontroller used in this lab board) is used as an output port, the ability to pull current (output current to the outside) is μA, which is insufficient to light up a light-emitting diode. The sink current (inward input current) can be as high as 20mA. Therefore, the current sink is used to drive the LED. Of course, today's enhanced microcontrollers use a pull-current output (connection 2) as long as the microcontroller's output current capability is sufficiently strong. In addition, the resistance in Figure 4 is 1K, which is to limit the current and limit the operating current of the LED to 2mA~10mA.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 4 LED connection

Fourth, program design

In the microcontroller programming language, there are two options for C language and assembly. This series of tutorials uses the C language to write programs. Here, simple comparisons are made between the C language and the assembly language when developing single-chip microcomputers. The assembly language is hardware-oriented, requires familiarity with hardware features such as registers, and has high execution efficiency. The readability and portability are poor. The programs between different microcontrollers cannot be used universally. For example, the assembly instructions of 51 single-chip microcomputers can not be used on AVR microcontrollers. C language is process-oriented, readability and portability are good, and efficiency is lower than assembly. For those who have just come into contact with the MCU, learning the two languages ​​is the same, but in the future development efficiency, the advantages of the C language are reflected. It can be transplanted almost completely without change, greatly improving the development. speed.

C language source program that controls LED D1 blinking:

1. Detailed description of the program

(1) The header file contains. The next call to the program P0_0 is a register address defined in the header file. Before registering the internal registers of the microcontroller, it should be stated where it came from. Interested readers can look at the contents of the AT89X52.h file.

(2) macro definition led, easy to understand and easy to modify the program, the P0_0 port named led, so that you can use the LED instead of P0_0 mouth to operate in the program.

(3) Delay function declaration. The function must be declared before the call. Since the function definition is placed after the main function, the delay function is declared before the main function.

(4) The main function entry. The main function does not pass arguments nor return a value.

(5) Dead Loop.

(6) Output high, led not bright.

(7) Delay for a period of time so that the human eye can see it intuitively.

(8) output low, led light.

(9) Delay for a while.

(10) Delay function definition.

(11) for statement loop delay.

2. Program flow chart and experimental phenomena

The program flow is shown in Figure 5. Compiled by the compiler (keil) to generate a single-chip microcomputer program file, and then can be downloaded to the internal operation of the microcontroller, the hardware circuit board shown in Figure 6, this experiment board is used STC89C52RC, you can use the USB port through the serial port Write the program. So connect the USB cable (found in this lab suite) to the computer and experiment board. The power supply can be taken from the USB or from an external power source. Cold start, ie click on the download first and then on again. After downloading the program into the MCU, you can see that the external LED (D1) of P0_0 on the experiment board is blinking.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 5 program flow chart

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 6 Hardware Board Diagram

V. Summary

This lecture mainly introduces the design of the 51-chip minimum system and the first simple program. From this experiment, you can master the development flow of the microcontroller and get started quickly. There are several issues that should be noted in this lecture:

1. The program was written in C language in this lecture, because of the readability and portability of C language. If you have not studied C language, you should understand and master the corresponding C language knowledge. The C language is easy to learn and easy to use.

2. The program compilation software uses Keil. Due to lack of space, I will not talk about it here. If readers don't understand it, they can go to the SCM forum of this forum. The author produced a detailed Keil tutorial. We use Keil to compile the program and eventually generate the Hex code file that writes the microcontroller.

The Keil software interface is shown in Figure 7. The middle blank area is the code area. The left side is the item list and the bottom is the message window.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 7 Keil Software Development Interface

3. The STC microcontroller used on this lab board downloads the program through the serial port. The upper computer software interface is shown in Figure 8. The programming operation is very simple. After clicking the “Open File” button to browse to find the Hex file to be programmed, the microcontroller will be powered off, click the “Download” button, and the microcontroller will be powered on. Can be downloaded to the microcontroller.

[skill seconds get] microcontroller minimum system composition and I/O output control knowledge learning

Figure 8 STC programming software interface

4. Product components

If the reader understands and practices according to the content of the lecture, it can be said that even if the single chip microcomputer is used as a starting point.

HP Adapter

Laptop power adapter charger for HP:

Laptop Brand Power Adapter
EliteBook 8440p 6530b 18.5v 3.5a, 7450
Compaq 6500b 6530b 6535b 6700b 6730b 6735b 6736b 19v 4.74a, 7450
Pavilion DV4 DV5 DV6-1000 CQ60 CQ61 18.5v 3.5a, 7450
COMPAQ Mini 19v 1.58a, 4017
2710p 2730p 2740p 2740w 2760p 18.5v 3.5a, 7450
Pavilion DV4 DV5 DV5T DV6 G50 G60 G70 HDX16 18.5v 3.5a, 7450
dm4-1000 Dm4t-1000 Dm4t-1100 DV3-4000 CQ42 18.5v 3.5a, 7450
Compaq Presario CQ42 CQ57 CQ72 CQ56 CQ32 CQ32-101TX I84C 18.5v 3.5a, 7450
G62 Compaq Presario CQ42 CQ72 CQ62 CQ56 CQ32 593555-001 DM4 18.5v 3.5a, 7450
DV4 DV5 DV6-1000 DV6-1200 DV6-1300 18.5v 3.5a, 7450
DV4 SPARE 18.5v 3.5a, 7450
dv4-1120us dv4-1200 dv6-2150us dv6-2155dx dv6-1245dx 18.5v 3.5a, 7450
Pavilion DV1000 DV1100 D1200 DV1300 18.5v 3.5a, 4817
DV1000 M2000 18.5v 3.5a, 4817
EliteBook 2730p 2740 2760p Compaq 2710p nc6320 18.5v 3.5a, 7450
Compaq 320 321 325 326 420 620 621 421 19v 4.74a, 4817
Pavilion dv4000 dv4100 dv4300 dv4400 19v 4.74a, 4817
Compaq DV1000 G3000 G5000 18.5v 3.5a, 4817
dv4-5000 dv6-7000 dv7-7099 19v 4.74a, 4817
dv6-7200 dv7-7200 DV4-5000 DV7-7000 19v 4.74a, 4817
DV4 DV6 CQ60 CQ70 G50 G70 18.5v 3.5a, 7450
ProBook 4340s 4341s 19v 4.74a, 7450
Pavilion DV3 19v 4.74a, 7450
ProBook 4320s 4321s 4325s 4420s 4425s 4525s 18.5v 3.5a, 7450
dv2000 dv6400 dv6700 dv6800 dv6900 A900 V6400 18.5v 3.5a, 4817
Compaq 420 421 425 4320t 620 625 320 321 325 326 621 18.5v 3.5a, 7450
ProBook 6440b 6445b 6450b 6540b 6545b 6550b 6555b 19v 4.74a, 7450
Pavillion DV7 19.5v 4.62a, 7450
G42 G72 G32 DV7-4000 DV6-6000 DV5-2000 19.5v 4.62a, 7450
Presario CQ32 CQ42 CQ43 CQ56 CQ62 CQ72 19v 4.74a, 7450
Pavilion DV6 DV6-3000 DM4-1000 Envy 15 17 G4 G6 G7-1000 19.5v 4.62a, 7450
avilion dm3 dm3-dm3t-1000 CTO dm3-1000 dv4-3100 19.5v 3.33a, 4817
DV4 DV5 G50 G60 G61 G70 G71 HDX16 19v 4.74a, 7450
CQ40 CQ50 CQ60 CQ61 CQ70 CQ71 DV4 19v 4.74a, 7450
CQ60 CQ61 CQ40 CQ41 CQ45 CQ60 G60 G70 19v 4.74a, 7450
Pavilion dm3 CTO dm3-1000 dv4-3100 19v 4.74a, 7450
Compaq 6520 6520P 6520S 515 516 19v 4.74a, 7450
2000-425NR 19v 4.74a, 7450

Our service:

Stable output and high charging efficiency.

Elegant outlook design as original one, touch smoothly and comfortable.

Original charger is good, but as a replacement, our product has more reasonable price when your original charger is broken.

And, the market of the replacement adapters becomes bigger and bigger. People would rather buy a copy one then the original because of the price.

But at the same time, people worry about that they will buy something defective. So the problem comes, how to buy a good quality one with a good price?

As a professional power adapter manufacturer, we have excellent R&D team, skilled staffs and responsible after-sale service. All your benefits can be under protected after you buy products for our company.

Our certificates :ISO9001:2008 & ISO14001:2004 , CCC , CE , FCC , ROHS.

All our products has 1 year warranty. In other words, if you get the dad products which are not damaged physically from us in one year, we will replace you the new one or the whole bulk order.

Laptop Adapter For Hp,Hp Laptop Adapter,Charger For Hp,Power Supply For Hp

Shenzhen Waweis Technology Co., Ltd. , https://www.waweisasdapter.com