51 single chip microcomputer learning record - digital tube dynamic display

Publisher:深沉思考Latest update time:2016-06-03 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I am currently learning about 51 digital tubes and interrupts, and plan to use a six-digit digital tube to implement a clock function.

However, when using digital tube output, if no delay statement is added, the display will always be confusing, and sometimes the numbers cannot be distinguished at all.

If there is a 1ms delay after the data is transmitted, the display confusion will improve.

At the same time, it is found that the longer the delay time, the better the display effect. However, of course, the corresponding display stability will also decrease, that is, the digital tube flickers.

The program has used the "Eliminate" statement in the reference book after sending the segment selection data:

1 dula=1;
2 P0=table[k];
3 dula=0;
4 P0=0xff; //"disappear"

But this statement is only effective when there is a delay. If I don't write a delay statement, the display will still be confusing.

Although the delay in the display process will not affect the interrupt timing, I don't want to rely on the delay written by the for statement.

So I tried many methods to solve this problem. My goal was to make the digital tube display normally without writing delay statements.

I have tried sending data to P0 first, then opening the latch, and then closing it immediately.

like:

1 P0=table[k];
2 dula=1;
3 dula=0;

But the problem remains

I also tried locking the other latch (i.e. sending a low level once) before opening any latch, but it still didn't work.

Finally, I found that I needed to add this code before outputting the data:

1 P0=0xff;
2 wela=1;
3 wela=0;
4 P0=0x00;
5 dula=1;
6 dula=0; //initialize to eliminate interference

After adding this code, the digital tube display is no longer chaotic. The function of the statement is similar to initializing the contents of the latch.

 

After two days of research, I finally figured out the trick. Now I share it with you: (Please indicate the source if you reprint it)

The fundamental reason why the digital tube has a "shadow" is that the segment selection and bit selection data cannot be delivered at the same time.

To explain it in detail: After I changed the value of the bit selection (changed the digital tube to be displayed), I changed the value of the segment selection (changed the number to be displayed). In the meantime, there was a small time interval, the value of the bit selection changed, but the value of the segment selection did not change. In other words, I changed the digital tube to be displayed, but this digital tube displayed the number of the previous digital tube! Thinking of this, I was enlightened! Of course, vice versa, if you select the segment first and then the bit selection, there will be the same problem. Please think about it yourself.

So it is not difficult to explain the role of the above code, which is to display the previous digital tube as blank (or not select any digital tube) before output.

So obviously this initialization code can be simplified, but it depends on whether you select the segment first or the bit first. If you select the bit first, then you have to clear the segment selection data.

1 P0=0x00;
2 dula=1;
3 dula=0;

The same is true in reverse. If you select the segment first, then clear the bit selection data.

 

Someone asked a similar question on Baidu Encyclopedia, which I quote here for your reference:

51 single chip microcomputer learning record - digital tube dynamic display

 

Experience summary: The display of the digital tube, the segment selection data and the bit selection data should be close together, and no other statements should be mixed in between. In other words, calculation should be done first, and data should be transmitted all at once at the end.

Reference address:51 single chip microcomputer learning record - digital tube dynamic display

Previous article:89S51 single chip microcomputer realizes the timing program with error of several microseconds
Next article:51 MCU learning summary example

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号