Now we start to do the actual welding, but the final result is not the same as the simulation.
[Copy link]
邀请:@黑衣人
@呱呱
@open82977352
@jinpost
@EEW
@xu__changhua
@quanzx
@zhangkai0215
参与回复
It took a long time, and now I finally finished welding the physical object. When burning, I found that I bought the wrong chip. I bought the STC10F08XE chip, and the chip I simulated was the STC89C51 chip. I bought the upgraded version. Then when the program was running, it was different from my proteus simulation. It can be seen that it has some similar rules to what I designed, but the speed is much faster than what I designed. But I think I connected an external 12M crystal oscillator, and when burning, I also saw that the current crystal oscillator is 11.98, which is very close to 12m, but why is it so fast? I modified the delay setting in my program, which is a little slower, but still fast. There was a four-second yellow light flashing at the end, and it was gone directly. Can anyone help me with what to do next?
#include<reg51.h>
#include<intrins.h>
sbit SRCLK=P3^6;
sbit RCLK=P3^5;
sbit SER=P3^4;
#define hang P0
unsigned char code TAB[8] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
unsigned char code CHARCODE[8][8]=
{
0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x66,0x3C,0x18, 0x00,0x00,0x00,0x00,0x00,
0xDB,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,
0x18,0xDB,0x66,0x3C,0x18,0x00,0x00,0x00,
0x66,0x3C,0xDB,0x66,0x3C,0x18,0x00,0x00,
0xC3,0x66,0x3C,0xDB,0x66,0x3C,0x18,0x00,
0x00,0xC3,0x66,0x3C,0xDB,0x66,0x3C,0x18,
};
void ys() //@12.000MHz
{
unsigned char i, j, k;
i = 46;
j = 153;
k = 245;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<121;j++);
}
void Hc595SendByte(unsigned char dat)
{
unsigned char a;
SRCLK=0;
RCLK=0;
for(a=0;a<8;a++)
{
SER=dat>>7;
dat<<=1;
SRCLK=1;
_nop_();
_nop_();
SRCLK=0;
}
RCLK=1;
_nop_();
_nop_();
RCLK=0;
}
void xs(unsigned int o)
{
unsigned char tab, j;
unsigned int i;
unsigned int p=1;
unsigned int k;
for(k=0;k<o;k++) //Changing the value can change the non-displayed time
{
ys();
}
while(p)
{
for(i= 0; i<50; i++ )
{
for(tab=0;tab<8;tab++)
{
Hc595SendByte(0x00);
hang = TAB[tab];
Hc595SendByte(CHARCODE[j][tab]);
delay(2);
}
}
j++;
if(j == 8)
{
j = 0;
}
p++;
if(p == 16) //Modifying the value can change the display duration
{
p = 0;
}
}
}
void hld()
{
unsigned char t;
t=0;
P1=0X61; //1:20s 1;20s
P2=0X11;
xs(4);
t=0;
P1=0X51; //2:4s 1:4s
P2=0X11;
while(t<4)
{
ys();
t++;
}
t=0;
P1=0X89; //3:16s 2:16s
P2=0X0c;
xs(0) ;
t=0;
P1=0X89; //3:4s 3:4s
P2=0X0a;
while(t<4)
{
ys();
t++;
}
t=0;
//////////////// ///////////////////////////////
P1=0X4c; //4:20s 1:20s
P2=0X11;
xs(4);
t=0;
P1=0X51; //5:4s 1:4s
P2=0X11;
while(t<4)
{
ys();
t++;
}
t=0;
P1=0X89; //6:16s 2:16s
P2=0X0c;
xs(0);
P1=0X89; //6:4s 3:4s
P2=0X0a;
while(t<4)
{
ys();
t++;
}
t=0;
}
void main()
{
while(1)
{
hld();
}
}
This is a program, this is a traffic light program with an indicator light. Thank you
|