Many people will encounter the situation when learning single-chip microcomputers. The program is beautifully written and the principle is thoroughly understood, but... I don’t know how to use the compiler software and how to download the program. It seems that my teacher didn’t teach me this in college, haha. So today I will mainly talk about the application of these two software.
Note: There are many types of microcontrollers, so there are naturally many types of compilation environments. It will definitely take some time to learn a compilation software, but the software interfaces are basically the same. Once you learn one, it will be quick to learn another. There is also a phenomenon that many people like to use the Chinese version, but I personally feel that it is unnecessary. First of all, the Chinese version is not necessarily standard; secondly, there are only a few words in the tool English, and it is OK to remember them. The Chinese version will increase unnecessary trouble.
Okay, enough nonsense, let’s get started!
Let's talk about Keil Uvision first. The first step is to double-click to open the software. The interface is as follows:
To write code, you need to create a new project, click: Project->New uvision project, and the following interface will pop up:
Create a separate folder for each project, such as LED01, and then enter the project name, which can be the same as the folder name, such as LED01. Click Save.
Note: This software does not need to consider the issue of Chinese and English paths. As far as I can remember, when debugging CPLD, the project generated by the software will go wrong if it is saved in the Chinese path.
After saving, the following interface appears:
Select the chip to be used in this interface. We use STC89C52C microcontroller, which is not included here, but you can use ATMEL's AT89C52 instead. Find the corresponding chip, select it, and click OK. The following interface pops up, click No:
The page is as follows:
Next, we need to create a document and write the code in it. Click File->New, create a new page, enter main.c, and then click Save to save the file as a C file, as shown below. After using it more, you will know that the two most commonly used files in microcontrollers are C files and H files.
Then right-click Source Group->Add Existing Files to Source Group 1, and the following interface pops up:
Select the main.c file we just saved and click Add. Why do we emphasize clicking here? Because you won’t see any changes after clicking. The only change is that there is a plus sign in front of Source Group1. Then click Close to close the page.
Click the plus sign in front of Source Group1, main.c will appear, double-click it, and you can enter the code on the right page. Paste yesterday's code in, click the save and rebuild buttons, both of which are on the upper left of the page, you can try to find them yourself.
The results are as shown above, 0 errors, 0 warnings.
After the compilation is completed, a hex file will be generated. This file is what we will eventually download to the microcontroller. When you open the project we created, you will find that you cannot find the hex file. Why? Because one step is missing, which is also something many people often forget. Click Project->Options for Target, and the following page will appear. Click output, as follows:
Check Create HEX File, click OK, recompile and rebuild, and you will find that the hex file appears in the project folder.
The above is the process of using the compilation software. I am a little dizzy after taking so many screenshots. Now let’s move on to the downloading process, which is much simpler.
Currently, there are roughly two circuits for serial port downloading. One is a serial port circuit built with MAX232, which downloads through the UART port of the microcontroller, and the other side of the line needs to be connected to the UART port of the computer.
However, today's computers, whether desktops or laptops, rarely have UART ports, so the second type emerged.
The second method is to use USB to serial port, which converts the UART signal into USB signal. There are too many USB ports on computers, so this is convenient. The chip I use is CH340T. When using this type of chip, you need to install the driver on the computer. I will upload the driver to the attachment later.
After the driver is installed, right-click My Computer - Manage - Device Manager - Port and the COM port used will be displayed.
I used the second method, connecting the board to the computer and keeping it powered on. Open the software STC-ISP, the page is as follows:
Follow the instructions
Step 1: Select the microcontroller: STC89C52C
Step 2: Open the program file and select the hex file we just generated.
Step 3: Select the port and baud rate. The port we selected is the one we saw in the device manager-port. Mine is COM2. The highest baud rate is 115200 and the lowest is 2400.
Step 4: Do not change the current configuration.
Step 5: Click Download, then press the power button on the board to turn off the power, and then press it again to turn it on. If the program is successfully written, the following information will be displayed:
Well, so far, the use of compiling software and downloading software has been explained. You may learn it after reading it once and never read it again, but as long as it helps you, it is worth it. The programs and codes used in the tutorial are in the attachment, download them if you need them.
Previous article:Learning 51 MCU - instruction cycle and LED flashing
Next article:Preparation for learning 51 single chip microcomputer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Qorvo Design Tools - The Go-to Resource for RF Projects
- FPGA Learning
- Causes of circuit failure
- The RT-Thread MicroPython development environment version 1.0.0 has been officially released. Let me share it with you.
- "Recommend Chinese chips" + domestic chips
- 【NXP Rapid IoT Review】 NO3. Receiving data from the cloud
- Littelfuse Efficient, Reliable, Accurate Power Control and Circuit Protection Solutions
- What issues need to be considered when using MCU development boards as industrial application boards
- INA128 Instrument Amplifier
- EEWORLD University Hall ---- FPGA Tips for Ming Deyang