51 single chip digital tube dynamic display program

Publisher:psi33Latest update time:2013-03-21 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    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

Reference address:51 single chip digital tube dynamic display program

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

C51 dynamic display method of digital tube
Code: #include reg52.h #define uchar unsigned char #define uint unsigned int sbit dula=P2^6; sbit wela=P2^7; uchar num,dunum,wenum; uchar code table_du ={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; //Digital tube segment selection code uchar code table_we ={ 0xfe,0xfd,0xfb
[Microcontroller]
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号