Since the school's board is slightly different from the one I bought, for the sake of everyone's reading, all future program writing and burning will be based on the board given by the teacher.
1. Prepare in Advance
a Driver installation. Please note that it has been sent in the group. Please install the driver for the board.
b Burning software (burner) stc-isp (It should be noted here that the chip on the board is from stc, and you can also see its model number stc89c52RC. You can use stc's burning software)
Question: What is burning software?
A: It means downloading the machine language you have written (C or assembly) into the microcontroller in a certain way. This is called burning. (Just understand it this way for now)
c write software keil uVision 4 (I only use it to compile and generate hex files)
notpad++ (I use it to write C51 code, and then copy it to Keil. It is great for writing code, and it is domestic software, and most importantly, it is free)
Question: What is compiler software?
Answer: Compiler software can compile a large amount of code you write in the compiler into executable corresponding files.
In the microcontroller, keil is used to compile the written C code file into an executable .HEX file.
2 Let’s get started!
1 Connect the board to the computer via USB. (You should know how to do it, right?)
2 Open notapad++ and write c51 code (you can also write directly in keil, but I don’t like it, the reason will be explained later)
Note! 1 #include
2 sbit LED1 = P1^0; is a bit operation. Please note that there must be a semicolon ";" at the end of the statement.
LED1 is actually a variable name
3 void main() is the main function and there is only one
analyze:
P1^0 is P10, that is, P1.0 pin. There is such a sentence in the main function
LED1 = 0;
That is to set the P1.0 pin to a low level.
About Level
In our study, 0 is low level 0v
1 is high level 5v
The level of the computer's serial port here is MAX232 high level -12v, low level +12v, so it cannot be directly connected to the microcontroller
But! There is a MAX232 chip in the microcontroller that can convert the voltage level (you can find the development board schematic pdf)
OK, now we don't have to worry about the level problem. Let's go back to the running light and set P1.0 to a low level.
This picture is a bit complicated, let’s look at another one
In fact, they are the same. When P1.0 is set to a low level, the left side is the Vcc power supply, and when the right side is at a low level, there is a potential difference in the circuit, and current flows through.
If the opposite is true, P1.0 is set to a high level and current cannot pass through the diode.
Ok, I think you should understand!
3 Compile the program to generate a hex file
Create a new project
Select a file name and then confirm
Choose a model
atmel AT89c51
Here I would like to explain that Keil is a foreign software and does not have the STC model (but you can add it yourself)
However, since the AT89c51 core is the same, it is also possible to use atmel AT89c51
continue
New or (crtl+n) create and then copy the code written in natePad++ into it (ctrl+c and ctrl+v)
Click Save and pay attention to the file name (please do not use Chinese characters, and the suffix .c should be a c file)
Double-click the source group and add the c file.
Click on the hammer
Then set the crystal frequency in traget, 11.0592Mhz (this is not used now, but set it first)
Be sure to select create HEx File and click OK
Click rebuild to generate a hex file (this file is in the 51c file directory you created)
Note: The hex file name is the project name
4 Open the burning software stc-isp (burner)
Note 1 Choose the MCU model, we are stc89c52rc
If the model is incorrect, the program cannot be successfully burned.
2 Select the serial port. When the driver is installed, plug in the USB and select the serial port, which is usually the one with a long name.
This is com3
3 Open the target program
Click to repeat programming. Display the detection target MCU
Then press the power button in the MCU to turn off the power. Then turn on the power button (this is a cold start of the MCU~)
Display operation success means writing success
5. Rendering
As shown in the figure, the first running light LED1 lights up.
Previous article:51 MCU Learning Part 6 - 1.2 The first C51 program (lighting up the running light)
Next article:51 MCU Learning Road—— 1.1 Learning Preparation
- 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?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- STMicroelectronics IO-Link Actuator Board Brings Turnkey Reference Design to Industrial Monitoring and Equipment Manufacturers
- Melexis uses coreless technology to reduce the size of current sensing devices
- Amplifier Distortion
- Very useful, a summary of RF dry goods (worth collecting)
- Work (II) Implementation of Linear and Nonlinear Signal Source Based on MCU + FPGA
- [GD32L233C-START Review] 5. Flash Read and Write - Using Internal Flash to Store Data
- Preliminary analysis of DSP functions 101103
- A review of the 30-year global electronics industry
- "Hello, DSP world" project example for DSP primary programming
- Boot Sector (Boot Block) in Nor Flash
- Monostable delay circuit composed of single op amp
- 8051 is equipped with ZigBee's wheels, and the single-chip microcomputer enters the wireless market