Experiment on the dynamic display program of the single-chip digital tube. The digital tube display is generally divided into two driving modes: static display and dynamic display. Static display occupies more lines. This article introduces how to realize the dynamic display of the digital tube. It should be said that the dynamic display of the digital tube is an important way for the external command output of the single-chip microcomputer. Therefore, how to design the digital tube and the working principle of the digital tube, the method of digital tube display, and the anti-interference design of the digital tube display occupy an important position in the design of the single-chip microcomputer system. This example designs a software query program and a software delay program (to prevent interference) based on the system hardware, and roughly describes the working principle and reading method of a dynamic display of a digital tube.
s1 bit p0.0 ; Digital tube bit definition
s2 bit p0.1
s3 bit p0.2
s4 bit p0.3
s5 bit p0.4
s6 bit p0.5
s7 bit p0.6
s8 bit p0.7
LED_data equ p2; digital tube data definition
org 00h ; program starts
jmp main ; main program starts at
30H org 030h ; main program starts at 30H
main: MOV sp,#30h ; set up the stack
lcall rest ; call the initialization program
lcall pro_8led ; call the digital tube display program
jmp main ; return
;************ Initialization procedure***************
rest:MOV a,#00h ; Clear register
MOV b,#00h ; Clear register
MOV p0,#0 ; Disable digital tube display
MOV p2,#255 ;
MOV p1,0ffh ; Disable LED display
clr beep ; Disable buzzer
ret ; Return
;******** Digital tube display program****************
pro_8led:
MOV b,#32; Display 32 digits in total
clr psw.3; Reset register group
setb psw.4;
MOV r0,#00h ;Data display starts from 0
MOV r1,#01h ;Digital tube starts from the 1st
loop:MOV p0,r1 ;Light up the current digital tube
MOV a,r0 ;Prepare the first data
MOV dptr,#tab_nu ;Get the table header
MOVc a,@a+dptr ;Get the first data
MOV led_data,a ;Output to the display data port
lcall delay ; 500 ms delay
lcall delay ; 1 s delay
inc r0 ; prepare the next data
MOV a, r1 ; prepare the next digital tube
rlc a ; set the next digital tube
jc c1 ; display all 8 bits, transfer
MOV r1, a ; otherwise, set the next digit
djnz b, loop ; 32 numbers are not displayed, return to display
ret ; otherwise return to the main program
c1: MOV r1,#1 ;After 8 bits are displayed, restart the loop
clr c ;Set the display bit
djnz b,loop ;After 32 bits are displayed, return to redisplay
ret ;Otherwise return to the main program
;************* Digital tube display***********************************
;**************** Software delay 500ms *****************************
delay: push psw ; Save the original register content
clr psw.3 ;
clr psw.4 ; Set a new register group
MOV r0,#2 ; Delay parameter 1
MOV r1,#250 ; Delay parameter 2
MOV r2,#2 ; Delay parameter 3
dl1:djnz r0,dl1 ; Delay loop 1
MOV r0,#250 ;
dl2:djnz r1,dl1 ; Delay loop 2
MOV r0,#240 ;
MOV r1,#248 ;
dl3:djnz r2,dl1 ; Delay loop 3
nop ; Timing accuracy adjustment
pop psw ; Restore the original register
ret ; Return
;******************************************************************
;**********************************************************
;This is a digital display table, where numbers with decimal points are 16 larger than numbers without decimal points
; For example, the display code for 0 is 0; then the display code for 0. is 16; and so on.
tab_nu:
db 0c0h, 0f9h, 0a4h, 0b0h, 99h , 92h , 82h, 0f8h ; Numbers 0-7 without decimal point codesdb
80h , 90h, 88h , 83h , 0c6h, 0a1h, 86h, 8eh ; Numbers 8-f without decimal point codesdb
40h , 79h, 24h , 30h , 19h , 12h , 02h, 78h ; Numbers 0-7 with decimal point codesdb
00h , 10h, 08h , 03h , 46h , 21h , 06h, 0eh ; Numbers 8-f with decimal point codes
Previous article:Manual counter made with AT89S51 microcontroller
Next article:Design a digital voltmeter using AT89S51 microcontroller and ADC0809
Recommended ReadingLatest update time:2024-11-16 14:28
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- I don't understand this speed, is it normal? The environment is esp8266
- [Old Post] Richengfeng's Eighteen Dragon Subduing Palms in C Language
- Introduction to DSP GPIO
- Examples of embedded system security issues
- The tool is still in Beta state
- EEWORLD University ---- Introduction to Power Electronics
- What does inductance 10t mean?
- How to Improve Heat Dissipation Using PCB Design
- Does anyone know which layers of AltiumDesigner the PCB production file suffixes correspond to?
- Comparison of CC2540 and nRF51822 application development