Home > other >  Simple frequency counter why digital tube that is not shown, very urgent to solve
Simple frequency counter why digital tube that is not shown, very urgent to solve

Time:10-07


The code
# include
Bit int_flag;//timer 0, 1 S to sign a
Unsigned char volatile T0Count;//timer interrupt number of 0
Unsigned char volatile T1Count;
Unsigned char code table []//timer interrupt number 1
X5b x06 x3f={0, 0, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f};//display section of the code value is 123456789
Unsigned char code \ []={0 xfe, 0 XFD, 0 XFB, 0 xf7};//digital tube gate
Unsigned long sum;//1 s the total number of pulse in
Unsigned char Led [4];//Led display cache
Void delay (unsigned int num) {//software delay
While (num);//initialization timer 0
}
Void init (void) {
TMOD=0 x51;//T1 timer 0 in mode 1, counting timer 1
TH0=(65536-50000)/256;//timing 50 ms
TL0=(65536-50000) % 256;
TH1=0 x00;
TL1=0 x00;
}
Void disp (void) {//digital display
unsigned char i;
for(i=0; i<4. I++)
{
The P2=\ [I];//piece choose
P0=table [Led [I]];//get data show
Delay (100);//delay 1 millisecond
}
}
Void main (void) {
EA=1;//always interrupt
The init ();//initialize the timer
TR0=1;//timer start work
TR1=1;
ET1=1;//T0 break
ET0=1;
While (1) {
If (int_flag==1) {
Int_flag=0;
Sum=TL1 + TH1 + T1Count * 65536 * 256;//1 s calculated pulse number
//the data format, into a display of BCD
Led [3]=sum % 10000/1000;//show one thousand
Led [2]=sum % 1000/100;//show one hundred
Led [1] sum %=100/10;//display 10
Led [0]=sum % 10;//shows individual
T0Count=0 x00;
T1Count=0;
TH1=0 x00;
TL1=0 x00;
TR1=1;
}
Disp ();
}
}
Void int_t0 (void) interrupt 1 {
TH0=(65535-50000)/256;
TL0=(65536-50000) % 256;
T0Count + +;
If (20) T0Count=={
TR1=0;
Int_flag=1;
T0Count=0 x00;
}
}
Void int_T1 (void) interrupt 3 {
T1Count + +;
}

CodePudding user response:

Delay (100);//delay 1 millisecond
Adjust to 255 and proved

CodePudding user response:

reference 1/f, the wise know already should good karma response:
delay (100);//delay 1 millisecond
Adjust to 255 and proved

I can't not bright or simulation

CodePudding user response:

reference 1/f, the wise know already should good karma response:
delay (100);//delay 1 millisecond
Adjust to 255 and proved

You see whether there is something wrong with the program

CodePudding user response:

The finder also points some debugging judgment problem, first to debug is digital display, that is the window of the man and machine communication, you first take fixed value to the display to see if normal

CodePudding user response:

reference 1/f, the wise know already should good karma response:
delay (100);//delay 1 millisecond
Adjust to 255 and proved

Digital tube that is low level effective but my mouth that data is high level how to return a responsibility

CodePudding user response:

references a wise man should know already take good karma, 4/f, response:
finder also points some debugging judgment problem, first to debug is digital display, is that humans and machines communication window, you first take fixed value to the display to see if normal

Is the program? Specific how to do it! I've just started this is unlikely to

CodePudding user response:

If you don't want you to learn, so you this is at the bottom of the post links to relevant content, literally just can find a of the code.

CodePudding user response:

Send a value within the main function to digital display statement won't? !

CodePudding user response:

the wise know already quoted 7 floor should good karma response:
if you don't want to learn of your own, you this is at the bottom of the post more links to related content, just grab a can use the code to.

Is not I want to know that it is wrong I want to fix him

CodePudding user response:

Void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; Disp (); }

CodePudding user response:

references to the tenth floor wise men know already should good karma response:
void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; Disp (); }


Lit but no number

CodePudding user response:

references to the tenth floor wise men know already should good karma response:
void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; Disp (); }

First shows the 4321 and then turned into 0000

CodePudding user response:

Very well, shows the first then turned into a 0000, 4321 to know why? Put the code in the main loop and proved in
Void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; While (1) {disp (); }}

CodePudding user response:

references a wise man should know already take good karma 13 floor response:
is very good, shows the 4321 first and then changed into 0000, know why? Put the code in the main loop and proved in
Void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; While (1) {disp (); }}

This can maintain 4321 has been lit

CodePudding user response:

references a wise man should know already take good karma 13 floor response:
is very good, shows the 4321 first and then changed into 0000, know why? Put the code in the main loop and proved in
Void main (void) {Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4; While (1) {disp (); }}

I put the Led [0]=1; Led [1]=2; Led [2]=3; Led [3]=4 to remove the outside then I added a frequency but show 0000 measure not to come out

CodePudding user response:

The two program debugging, you should understand what is the cause of the twice the result, set the display, the following debugging
The sum first assignment: sum=1234; Then the following statements is normal
Led [3]=sum % 10000/1000;//show one thousand
Led [2]=sum % 1000/100;//show one hundred
Led [1] sum %=100/10;//display 10
Led [0]=sum % 10;//shows individual

CodePudding user response:

the wise know already quoted 16 floor should good karma response:
2 times this program debugging, what is the reason why you should see two results, set the display, the following debugging
The sum first assignment: sum=1234; Then the following statements is normal
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related