Home > other >  Please everyone a great god, I just started to learn counter 0 51 single-chip microcomputer and fall
Please everyone a great god, I just started to learn counter 0 51 single-chip microcomputer and fall

Time:09-20

Digital tube is a total of Yin, the board can display 00, but will not change,
#include
# define uchar unsigned char
# define uint unsigned int
Sbit dula=P2 ^ 6;//U1 latch end
Sbit wela=P2 ^ 7;//U2 latch end
Uchar code table []={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};
Void delayms (uint);
Void the display (uchar shi, uchar ge)
{
Dula=1;
P0=table (shi);
Dula=0;
P0=0 XFF;
Wela=1;
P0=0 xfe;
Wela=0;
Delayms (5);
Dula=1;
P0=table (ge),
Dula=0;
P0=0 XFF;
Wela=1;
P0=0 XFD;
Wela=0;
Delayms (5);
}
Void delayms (uint XMS)
{
Uint I, j;
For (I=XMS; I> 0; I -)
For (j=110; J> 0; J -);
}
Uint a read ()
{
Uchar t1, th1, th2;
Uint val.
While (1)
{
Th1=TH0;
T1=TL1;
Th2=TH0;
If (th1==th2)
break;
}
Val=256 + th1 * t1;
Return val.
}
Void main ()
{
Uchar a, b;
Uint num.
TMOD=0 x05;
TH0=0;
TL0=0;
TR0=1;
While (1)
{
Num=the read ();
If (num>
=100){
num=0;
TH0=0;
TL0=0;
}
A=num/10;
B=num % 10;
Display (a, b);
}
}
Then I use proteus simulation, digital tube actually cannot display properly, please instruct,

CodePudding user response:

While (1)
{
Th1=TH0;
T1=TL1;
Th2=TH0;
If (th1==th2)
break;
}
What do you mean by this code is

CodePudding user response:

Val=256 + th1 * t1;
How to use this code TH0 add TL1

CodePudding user response:

Feeling in a cluttered code, it is recommended that the original poster write code behind with annotations, C modular program more intuitive

CodePudding user response:

Sorry, look not to understand is how to calculate, have high 0 have high 1, feeling is a mess,
Timer value is 0? Usually to set a timer for timing value, then the highs and lows assignment, usually don't assignment is 0.

CodePudding user response:

I don't know your schematic diagram
But the display function should write
(didn't write for a long time, don't know right)
Dula=1;
Wela=0;
P0=table (shi);
Delayms (5);
Dula=0;
Wela=1;
P0=table (ge),
Delayms (5);

CodePudding user response:

Since your digital tube only 0-99
TMOD=0 x05 so you use should be counter 2
So just need to read low TH1 can count 0-255

CodePudding user response:

reference 1/f, introduction to embedded development response:
the while (1)
{
Th1=TH0;
T1=TL1;
Th2=TH0;
If (th1==th2)
break;
}
What do you mean by this code is

This is a confirmation to TH0 TL0 didn't carry it, but don't

CodePudding user response:

references a wise man should know already take good karma, 4/f, response:
I'm sorry, look not to understand is how to calculate, have high 0 1 has high, feel is a mess,
Timer value is 0? Usually back to set a timer for timing value, then the highs and lows assignment, is usually not assignment 0.

Ha, ha, ha, I'm too dishes, 51 timer 0, but this is not the timer, may I write is too disorderly
  • Related