Single-chip Computer Simulation

Source: Internet
Author: User

1. Open the Keil Software

2. Create text1

3. input the program (*** see Appendix 1)

4. Save it as a. c file

5. Create a project

6. Select Atmel-> AT89C51.

7. Right-click source group 1 of the new project and choose add file to Group 1.

8. Right-click the new project name> Option> output> and select create a. HEX file.

9. Compile to obtain the. HEX file;

 

1. Open protues

2. Draw a picture as follows:

3. Double-click the single-chip microcomputer. In the displayed dialog box, add the generated. HEX file to the program file.

4. debug-> exrcute

 

 

 

* ** Appendix 1

# Include <reg51.h> // the pre-processing file defines the names of special registers. For example, the P1 port is defined as P1.

Void main (void)

{

// Define pattern data

Const unsigned char design [32] = {0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f,

0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe, 0xff,

0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x0,

0xe7, 0xdb, 0xbd, 0x7e, 0xff };

Unsigned int A; // defines the variable used for Loop

Unsigned char B; // pay attention to the use of variable types due to limited memory in C51 programming.

// Use the smallest byte type as much as possible, which is very useful in large programs

Do {

For (B = 0; B <32; B ++)

{

For (A = 0; A <30000; A ++); // delay for a period of time

P1 = design [B]; // read the defined pattern data and write it to the P1 port.

}

} While (1 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.