If you get a chip and want to use it, you must first know how to connect it. The chip we use is called 89S52. Let's see how to connect it.
1. Power supply: This is of course essential. The microcontroller uses a 5V power supply, with the positive pole connected to pin 40 and the negative pole (ground) connected to pin 20.
2. Oscillator circuit: The microcontroller is a timing circuit that must provide a pulse signal to work properly. The oscillator has been integrated inside the microcontroller, using a crystal oscillator, connected to pins 18 and 19. Just buy a crystal oscillator and a capacitor and connect them. Just connect them according to Figure 1.
3. Reset pin: Connect according to the method in Figure 1. As for what reset means and why it is necessary to reset, it is introduced in the microcontroller function.
4. EA pin: The EA pin is connected to the positive power supply terminal. At this point, a microcontroller is connected, and the microcontroller starts working after power is turned on.
Of course, you don't necessarily need an 89S52. In fact, we can use any chip in the 8051 series, such as 89s51, 89c52, etc.
Our first task is to use a microcontroller to light up a light-emitting diode (LED). Obviously, this LED must be connected to a pin of the microcontroller, otherwise the microcontroller cannot control it. So which pin should it be connected to? In addition to the 5 pins just used, there are 35 pins on the microcontroller. Connect this LED to pin 1. (See Figure 1, where R2 is a current-limiting resistor)
According to the connection method in this figure, when pin 1 is at a high level, the LED will not light up, and only when pin 1 is at a low level, the LED will light up. Therefore, pin 1 must be controllable, that is, it must be able to make pin 1 become high or low as required. Since we want to control pin 1, we have to give it a name. We can't just call it pin 1, right? What name should we call it? INTEL, the company that designed the 51 chip, has already named it P1.0. This is a rule and cannot be changed by us.
Now that we have a name, how do we make it high or low? To tell someone to do something, we just need to say it, which is called issuing a command. To tell a computer to do something, we also need to send a command to the computer. The command that the computer can understand is called a computer instruction. The instruction to make a pin output a high level is SETB, and the instruction to make a pin output a low level is CLR. Therefore, if you want P1.0 to output a high level, just write SETB P1.0, and if you want P1.0 to output a low level, just write CLR P1.0.
Now there is a way to make the computer output P1.0 high or low, but how can the computer execute this instruction? You can't just tell the computer and leave it alone. To solve this problem, there are still a few steps to take.
First, computers cannot understand instructions such as SETB CLR. We have to translate the instructions into a way that computers can understand, and then let the computer read them. What can computers understand? They only understand one thing - numbers. Therefore, we have to change SETB P1.0 to (D2H, 90H) and CLR P1.0 to (C2H, 90H). As for why these two numbers are used, this is also stipulated by the designer of the 51 chip - INTEL, and we will not study it.
The second step is, after getting these two numbers, how to get these two numbers into the microcontroller? This requires the help of a hardware tool "programmer" or "ISP download cable" (the microcontroller supports online programming, and the ISP download cable can be used, which is more convenient and quick). Of course, if you use our microcontroller development test application board, then you have both the programmer and the test board, and you only need to program. The ISP download cable and test board download program interface are shown in Figures 2 and 3.
This is the first step to microcontroller programming. It may seem simple, but it is of great significance to you. Yes, you are programming: (
Open WAVE software; write the program,
We set its name to: sy1.asm; finally, burn the generated sy1.hex into the 89S52 of the microcontroller test development board. At this time, you can see that the p1.0 light is on.
This picture shows the 8 light-emitting diodes on the experimental development board. Note that it can be switched through a jumper switch next to it (light-emitting diode and LED display switch)!
At this time, some friends may ask: Why do we need to use a single chip microcomputer to make such a simple problem so complicated? If we connect a battery, won’t the light turn on?
That's right, but this is programming. If you don't want p1.0 to light up, but want p2.0 to light up, then just write clr p2.0, and you don't need to use a soldering iron to change the line. In this way, you can see that the connection of the hardware circuit has not been changed. As long as you change the content written into the microcontroller, you can change the output effect of the circuit.
It can be seen that problems that are very difficult to implement with hardware can be solved easily and quickly with a single-chip microcomputer.
Previous article:Using the T0 and T1 timing counter functions of the AT89S51 microcontroller
Next article:Answers to Common Exercises on MCS-51 MCU Timer/Counter
- Popular Resources
- Popular amplifiers
- 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?
- 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
- Another technical solution for power-type plug-in hybrid: A brief discussion on Volvo T8 plug-in hybrid technology
- Can I set the I2C pin on ESP32?
- ESD protection is carried out using capacitors. I have many problems. Please help!
- AUTOSAR’s popularity in automotive electronics software development
- GD32F103TBU6 cannot start normally
- Bluetooth EDR Technology and Applications
- Understand the perfect combination of RPA and AI in one article
- The S32K144\S32K148 program cannot be burned.
- The half-bridge chip 2104 drives a single NMOS on the high side. Is it theoretically possible?
- Why does this affect the analog signal?
- Noise Figure Measurement Handbook