Home > other > Protues single-chip microcomputer simulation problem of digital tube, each great god
Protues single-chip microcomputer simulation problem of digital tube, each great god
Time:09-17
Stopwatch simulation, two common cathode digital tube display the number of seconds, 10 on the number of flash only to display the time than the number of bits is short, what reason be? # include # define uint unsigned int # define uchar unsigned char Uchar temp, aa, shi ge; Uchar code table []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f};//common cathode digital tube spec Void the display (uchar shi, uchar ge); Void delayms (uint); Void init (); Void main () { init(); While (1) { If (aa==20) { Aa=0; Temp++; If (temp==59) { Temp=0; } Shi=temp/10; Ge=temp % 10; The display (shi ge); } } } Void delayms (uint XMS) { Uint x, y; For (x=XMS; X> 0; X -) For (y=110; Y> 0; Y -); } Void the display (uchar shi, uchar ge)//display subroutine { The P2=0 xfe; P1=table (shi); Delayms (5); The P2=0 XFD; P1=table (ge), Delayms (5); } Void init ()//timer initialization program { Temp=0; TMOD=0 x01; TH0=(65536-50000)/256; TL0=(65536-50000) % 256; EA=1; ET0=1; TR0=1; } Void timer0 () interrupt 1//T0 timer interrupt subroutine { TH0=(65536-50000)/256; TL0=(65536-50000) % 256; Aa++; }
CodePudding user response:
This should be your delay didn't handle, after each digit display not to delay to produce light for a period of time, you the delay may not be appropriate, in addition, after each digit display and time delay, and then let the segment output oxff (if digital section is a total of anode), to segment were closed, and then on to the next digit bit selection, segment and time delay
CodePudding user response:
Problem is always written as, P2 2 pin definition calls alone is better,