2880 views|6 replies

39

Posts

0

Resources
The OP
 

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

This post is from 51mcu

Latest reply

It is recommended to read the stc manual and examples carefully, it should not be too difficult.   Details Published on 2021-5-3 15:15
 

1w

Posts

204

Resources
2
 

Well, let's take a look at the parameters of the new chip. There may be some differences, so please calculate it carefully and confirm it.

This post is from 51mcu
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
Personal signature

玩板看这里:

https://bbs.eeworld.com.cn/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 

30

Posts

3

Resources
3
 

The STC10F08XE chip that the OP bought is a 1T MCU. Compared with the traditional 12T MCU such as STC89C51, the instruction running speed is 8-12 times faster at the same crystal frequency. Therefore, the soft delay also needs to increase the corresponding time.

This post is from 51mcu

Comments

I modified the corresponding delay program, 10 series of one second delay, but it is still relatively fast  Details Published on 2021-4-1 13:06
 
 
 

39

Posts

0

Resources
4
 
kiverin posted on 2021-3-30 13:24 The STC10F08XE chip bought by the OP is a 1T microcontroller. Compared with the traditional 12T microcontroller such as STC89C51, the instruction running speed is faster at the same crystal oscillator frequency...

I modified the corresponding delay program, 10 series of one second delay, but it is still relatively fast

This post is from 51mcu

Comments

You can hang up an oscilloscope and adjust the delay   Details Published on 2021-4-1 20:53
 
 
 

6593

Posts

0

Resources
5
 
Demonstration method published on 2021-4-1 13:06 I modified the corresponding delay program, 10 series of one second delay, but it is still relatively fast

You can hang up an oscilloscope and adjust the delay

This post is from 51mcu
 
 
 

7462

Posts

2

Resources
6
 

Check whether the crystal oscillator is normal. The frequency of STC is fixed.

This post is from 51mcu
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

927

Posts

0

Resources
7
 

It is recommended to read the stc manual and examples carefully, it should not be too difficult.

This post is from 51mcu
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list