Getting Started with 51 MCU - Lighting up the First LED

Publisher:superstar11Latest update time:2020-03-23 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Install burning software and add MCU

Since the chip I use is STC89C52, the STC series of microcontrollers are not integrated in the keil software, so I need to add it myself. So I log in to the STC official website http://www.stcisp.com to download the latest stc-isp software.


Then open stc-isp, select Keil simulation settings, and click to add the model and header file to Keil

Select the installation folder (the folder must include C51 and UVx, which is the installation directory of the Keil software)

Click OK, it will show that the STC MCU model has been added successfully, click OK and close the software.


Understanding the Principle

View the development board schematics

The LED schematic diagram of the development board used by the author is as follows, so we know that D1 is connected to the P20 interface.

LED lighting principle

Different light-emitting diodes have different forward conduction voltages, and the specific voltage drop depends on the diode query, but the same feature is that the positive voltage of the diode must be greater than the negative voltage. In the schematic diagram, the positive pole of the diode is connected to a resistor and then to Vcc, and the negative pole is directly connected to the P20 port. If Vcc is high, the P20 port is low. The resistor provides a voltage drop here to prevent the voltage at both ends of the D1 port from being too high and limit the current from being too large. So we get the parameters we need to set, the P20 port voltage is 0, that is, the parameter that needs to be set in Keil is that the P20 voltage is 0.


Programming

New Project

After creating a new project, select STC series and find the STC89C52 chip

Click OK and then select Yes to successfully create the project.


create a new file

Click new under File to create a new file, click Save, and the file extension will be .c

Double-click Source Group1 to add the file.

Compiling the code

Code

Click the magic wand and check the box next to the hex file under output.

Then compile the file, 0 warnings 0 errors and generate a hex file

Burn into MCU

Open the stc-isp software, select the MCU model, select the serial port number that is the same as the computer, then open the file and find the hex file just generated, which is usually under the generated Objects file

Select Download Programming and complete the operation when prompted

Now let’s take a look at the first LED light that lights up!

Reference address:Getting Started with 51 MCU - Lighting up the First LED

Previous article:Multi-mode 51 single-chip heart-shaped water light + breathing light + buzzer music
Next article:Microcontroller - Buzzer (Happy Birthday)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号