mdk program preparation
Open mdk5, create a new project, select AT89C51
configuration to generate a hex file, click the magic wand icon on the main page, select output, check Create HEX File, and then compile a hex file.
Right-click the file Source Group 1 for proteus simulation , Select Add New…
Enter the corresponding code in the creation file
Source code
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
main()
{ int i;
uint j;
uchar code tab[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};/*?????*/
while(1)
{for(i=0;i<=15;i++)
{P0=tab[i];
for(j=0;j<30000;j++);/*??*/
}
}
}
Proteus software design circuit diagram
Component selection:
89c51, transistor (7-SEG-COM-CAT-B), crystal oscillator (CRYSTAL), exclusion (RESPACK-7), resistance (RES), capacitance (CAP), button (button)
Power terminal POWER, ground GROUND to
complete the drawing.
Finally import the hex file generated by the mdk compiler, double-click the c51 chip, and
finally debug and run successfully in proteus
to sum up
This time, I did it according to the blog of a blogger. Although I didn't do it myself, I couldn't help but be happy when I succeeded.
Imitation from: https://blog.csdn.net/weixin_46522844/article/details/108954570 .