STC89C52 microcontroller digital tube static display

Publisher:乐呵的挑Latest update time:2022-10-20 Source: csdnKeywords:STC89C52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Digital tube display principle

Insert image description here

Digital tubes are divided into common cathode and common anode according to different internal connections. There are 8 LEDs inside the eight-segment digital tube. If you want to display a specific font, you only need to control the corresponding LED to light up and the other LEDs to turn off.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-c7ppkdZI-1604209821031) (img/code_table.png)]

Static and dynamic display

Static display:

There are two working modes of LED displays: static display mode and dynamic display mode. The characteristic of static display is that the segment selection of each digital tube must be connected to a 9-bit data line to maintain the displayed glyph code. After the glyph code is sent once, the displayed glyph can be maintained until a new glyph code is sent.

Disadvantages: More IO ports are used.


dynamic display

The characteristic of dynamic display is that the segment selection lines of all digital tubes are connected in parallel, and the bit selection lines control which digital tube is effective. The selected digital tube adopts dynamic scanning display. The so-called dynamic scanning display is to send glyph codes and corresponding bit selections to each digital tube in turn. It uses the afterglow of the luminescent tube and the persistence of human vision to make people feel as if all the digital tubes are displaying at the same time.


How the 74HC573 latch works

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-zlCrpAey-1604210100233) (img/74HC573.png)]

Chip document query website: https://www.alldatasheet.com/


The role of pull-up resistors

Pull-up is to clamp the uncertain signal to a high level through a resistor, and the resistor also acts as a current limiter. In the same way, the lower level also clamps the uncertain signal at a low level through a resistor.


When the P0 port is used as an input or output port, it is in open-drain mode after power-on reset. There is no pull-up resistor inside the P0 port, so the I/0 port must be connected to an external pull-up resistor of 10K-4.7K.

Insert image description here

Light up the single digit "1"

#include

#include


#define uint unsigned int

#define uchar unsigned char


sbit DU = P2^6;//digital tube segment selection

sbit WE = P2^7;//Nigital tube segment selection


void main(){ // The main function itself will loop

WE = 1; //Open bit select latch

P0 = 0XFE; // 1111 1110 strobe the first digital tube

// P0 = 0X00; // 0000 0000 means strobing all digital tubes

WE = 0; //Latch bit selection data

DU = 1; //Open segment selection latch

P0 = 0X06; // 0000 0110 displays "1"

DU = 0; //Latch segment selection data

while(1){

   // P0 = 0X01; // When the value in the latch is locked, the value of the digital tube cannot be modified directly. You need to open the bit selection latch to modify it.


}

}


Light up the two-digit number "2"

#include

#include


#define uint unsigned int

#define uchar unsigned char


sbit DU = P2^6;//digital tube segment selection

sbit WE = P2^7;//Nigital tube segment selection


void main(){ // The main function itself will loop

WE = 1; //Open bit select latch

P0 = 0XFC; // 1111 1100 strobe the first and second digital tubes

// P0 = 0X00; // 0000 0000 means strobing all digital tubes

WE = 0; //Latch bit selection data

DU = 1; //Open segment selection latch

P0 = 0X5B; // 0101 1011 displays "2"

DU = 0; //Latch segment selection data

while(1){

   // P0 = 0X01; // When the value in the latch is locked, the value of the digital tube cannot be modified directly. The latch needs to be opened to modify it.


}

}


Light up the three-digit number "3"

#include

#include


#define uint unsigned int

#define uchar unsigned char


sbit DU = P2^6;//digital tube segment selection

sbit WE = P2^7;//Nigital tube segment selection


void main(){ // The main function itself will loop

WE = 1; //Open bit select latch

P0 = 0XF8; // 1111 1000 selects the first, second and third digital tubes

// P0 = 0X00; // 0000 0000 means strobing all digital tubes

WE = 0; //Latch bit selection data

DU = 1; //Open segment selection latch

P0 = 0X4F; // 0100 1111 displays "3"

DU = 0; //Latch segment selection data

while(1){

   // P0 = 0X01; // When the value in the latch is locked, the value of the digital tube cannot be modified directly. The latch needs to be opened to modify it.


}

}


Light up the last digit "8" of the digital tube

#include

#include


#define uint unsigned int

#define uchar unsigned char


sbit DU = P2^6;//digital tube segment selection

sbit WE = P2^7;//Nigital tube segment selection


void main(){ // The main function itself will loop

WE = 1; //Open bit select latch

P0 = 0X7F; // 1111 1000 strobes the eighth digital tube

// P0 = 0X00; // 0000 0000 means strobing all digital tubes

WE = 0; //Latch bit selection data

DU = 1; //Open segment selection latch

P0 = 0X7F; // 0111 1111 displays "8"

DU = 0; //Latch segment selection data

while(1){

   // P0 = 0X01; // When the value in the latch is locked, the value of the digital tube cannot be modified directly. The latch needs to be opened to modify it.


}

}


Make the third (from left to right) digital tube display the number 6

#include

#include


#define uint unsigned int

#define uchar unsigned char


sbit DU = P2^6;//digital tube segment selection

sbit WE = P2^7;//Nigital tube segment selection


void main(){ // The main function itself will loop

P0 = 0X00; //Clear broken code

WE = 1; //Open bit select latch

P0 = 0X03; // 0000 0011 Strobe the 3rd, 4th, 5th, 6th, 7th and 8th digital tubes

// P0 = 0X00; // 0000 0000 means strobing all digital tubes

WE = 0; //Latch bit selection data

DU = 1; //Open segment selection latch

P0 = 0X7D; // The corresponding digital tube letter acdefg of 0111 1101 displays "6"

DU = 0; //Latch segment selection data

}

Insert image description here

Keywords:STC89C52 Reference address:STC89C52 microcontroller digital tube static display

Previous article:STC89C52 microcontroller digital tube dynamic display
Next article:STC89C52 microcontroller buzzer

Recommended ReadingLatest update time:2024-11-16 10:35

Practical analysis of 8051 microcontroller (taking STC89C52RC as an example) | 09 - LED dot matrix display of numbers
1 LED dot matrix LED dot matrix is ​​a display device composed of light-emitting diodes. It can be seen everywhere in our daily electrical appliances and is widely used in bus station announcers, advertising screens, etc. The 8*8 dot matrix is ​​usually used more often, and then multiple 8*8 dot matrices can be used t
[Microcontroller]
Practical analysis of 8051 microcontroller (taking STC89C52RC as an example) | 09 - LED dot matrix display of numbers
51 single chip microcomputer STC89C52 controls the LED water light to shift left (using bit operators)
/*-----------------------Include header file area-------------------------*/ #include reg52.h   //MCU header file  /*-----------------------Function declaration area---------------------------*/  void delay(unsigned int xms); //delay function declaration /*-----------------------Main function area-------------------
[Microcontroller]
STC89C52 drives MAX7219LED dot matrix cascade, text scrolling effect
Value transfer method under cascade In cascade, N MAX7219s form a latch with a width of 8*N bits. If you need to write to the Mth 7219, you need to do M addressing + pull up CS after writing to reach this 7219. If you only operate this 7219 and do not operate other 7219s, then after the first addressing write, the add
[Microcontroller]
51 microcontroller-STC89C52 series learning Part 3: Interrupt learning
Eight interrupt request sources: 1. External interrupt 0 2. External interrupt 1 3. External interrupt 2 4. External interrupt 3 5. Timer 0 interrupt 6. Timer 1 interrupt 7. Timer 2 interrupt 8. Serial port interruption All interrupts have four interrupt priority levels: Priority 0: 0,0 (lowest) Priority 1: 0,1 Prio
[Microcontroller]
51 microcontroller-STC89C52 series learning Part 3: Interrupt learning
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号