A simple example of Proteus 8 simulation software and the sequential lighting of the LEDs of the C51 microcontroller

Summary: This simulation requires the use of PC, keil software , proteus software and the corresponding basic C language knowledge.
Brief summary: Use the 89C51 chip of the single-chip microcomputer to connect 8 LED tubes, and connect a debounce switch from /INT0. Each time you press the switch, the next LED will light up and move down in sequence.

1. LED lighting program compilation

1. Open the Keli 4 software and create a new project file

Insert picture description here

2. Look for the AT89C51 chip in the Atmel catalog

⑴Expand the Atmel catalog

Insert picture description here

⑵Select AT89C51 and click to confirm

Insert picture description here

3. Create a new text under the project for C language compilation

⑴New text

Insert picture description here

⑵Enter the relevant code

#include<reg51.h>
int0 () interrupt 0
{
    
    
    P1=P1<<1|0x01;  
}
main()
{
    
    
   P1=0xfe;  //选择LED接入口
   EA=1;
   EX0=1;
   IT0=1;
   do{
    
    }while(1);
}

* Note: Because the text file was used before, it is still a text file compiled by Keil software at this time.

(3) Compile the text file with C language program

Save the compiled file as a C language source
Insert picture description here
Insert picture description here
program. After adding .c to the file name suffix, the file will automatically generate a C language source program.

⑷Add the C language file to the project with C51

Insert picture description here
At this time, the directory will let you select the files that need to be added, we find the previously saved C language program and click Add

4. Convert C language to hex file

The hex file format is a file format that can be written to and executed by the microcontroller (the explanation comes from Baidu Encyclopedia). So we need to generate a hex file for subsequent software simulation and debugging.

⑴Choose the magic wand

Insert picture description here

⑵Select "Output" and click "Create HEX File", then click "OK" to confirm.

Insert picture description here

The quoted text now shows that the hex file has been successfully generated, and the
Insert picture description here
software preparation is complete

Two, Proteus simulation

1. Open the Proteus software to create a new schematic design

Insert picture description here

2. Select components to design the circuit

⑴Select the component library, search for the desired component

Insert picture description here

⑵Draw circuit diagram

Insert picture description here

This circuit is a little simpler and can run normally after the author's test.

⑶ Put the previous hex file into the C51 chip

Double-click the C51 chip and select the file.
Insert picture description here
Find the hex file saved in the directory and add it
Insert picture description here

⑷ Simulation results

Insert picture description here

Three, summary

Using keil and protues to carry out the most basic software development, initially contacted the relationship between software and hardware, and gradually became clear about the relationship between software and hardware. But it is only an entry-level example, not an in-depth discussion of Proteus and C51 microcontroller.

Guess you like

Origin blog.csdn.net/weixin_47357131/article/details/108960957