Use the microcontroller AT89C51 to drive the two-digit digital tube to display 00--99 in order to cycle the program code

Publisher:WanderlustSoulLatest update time:2023-01-12 Source: zhihu Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;The two-digit digital tube displays 00--99 in sequence.

org 0000h

a_bit equ 20h; The single digit of the digital tube stores the memory location

b_bit equ 21h; The tens digit of the digital tube stores the memory location

temp equ 22h ;The counter value is stored in the memory location

star: mov temp,#0; initialize counter, starting from 0

stlop: acall display; call display subroutine

inc temp; add 1 to the counter

mov a,temp

cjne a,#100,next ; Determine whether the counter is full of 100?

mov temp,#0; clear it when it reaches 100 and start again

next: ljmp stlop; loop if not satisfied

;display subroutine

display: mov a,temp ;Convert the hexadecimal number in temp to decimal

mov b,#10 ;decimal/10=decimal

div ab

mov b_bit,a ; the tenth bit is in a

mov a_bit,b ;the ones bit is in b

MOV DPTR,#NUMTAB; specifies the starting address of the table lookup

mov r0,#4

dpl1: mov r1,#250;

dplop: mov a,a_bit; take single digit

MOVC A,@A+DPTR; Check single-digit 7-segment code

mov p0,a ;send 7 pieces of code of units digit

clr p2.7; turn on ones digit display

acall d1ms ;display 162 microseconds

setb p2.7; turn off the units display to prevent ghosting

mov a,b_bit ; take ten digits

MOVC A,@A+DPTR; Check 7 code segments with ten digits

mov p0,a ;send 7 pieces of code with ten digits

clr p2.6; Turn on tens digit display

acall d1ms ;display 162 microseconds

setb p2.6; turn off tens digit display to prevent ghosting

djnz r1,dplop; loop executed 250 times

djnz r0,dpl1; loop execution 250X4=1000 times

ret

;2+2X80=162 microseconds, the delay is calculated according to 12MHZ

D1MS: MOV R7,#80

DJNZ R7,$

RET

;The common cathode display code of the 7-segment digital tube from 0 to 9 on the experimental board

NUMTAB:DB 0CFH,03H,5DH,5BH,93H,0DAH,0DEH,43H,0DFH,0DBH

end


Reference address:Use the microcontroller AT89C51 to drive the two-digit digital tube to display 00--99 in order to cycle the program code

Previous article:Single chip microcomputer lighting (lighting, flashing, running light)
Next article:Use the microcontroller AT89C51 to make an 8-way running water lamp

Latest Microcontroller Articles
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号