Here is a 51 single-chip electronic clock assembly program design method:
org 00h
a_bit equ 30h ; second register
b_bit equ 31h ; 10
second register
c_bit equ 32h ; minute register d_bit equ 33h ; 10 minute register
e_bit equ 34h ; hour register
f_bit equ 35h ; 10 hour register
org 0000h
ajmp star
org 0030h
star:
mov a,#00h ; clear all bits to 0
mov a_bit,a
mov b_bit,a
mov c_bit,a
mov d_bit,a
mov e_bit,a
mov f_bit,a
stlop: acall display ; calculation part of 51 single-chip electronic clock program
inc a_bit ;add 1 to the second bit
mov a,a_bit ;send a
cjne a,#10,stlop;if the second reaches 10, then go to 10 seconds processing
mov a_bit,#00h ;clear the second bit to 0
inc b_bit ;add 1 to the 10 seconds
bit mov a,b_bit ;send a
cjne a,#6,stlop ;if the 10 seconds reaches 6, then go to minute processing
mov b_bit,#00h ;clear the 10 seconds bit to 0
inc c_bit
mov a,c_bit
cjne a,#10,stlop
mov c_bit,
#00h
inc d_bit
mov a,d_bit
cjne a,#6,stlop
mov d_bit,#00h
inc e_bit
mov a,e_bit
cjne a,#10,stlop
mov e_bit,#00h
inc f_bit
mov a,f_bit
cjne a,#3,stlop
mov f_bit,#00h
ajmp stlop ; restart calculation
display: ;Display subroutine - 51 single-chip electronic clock directly displayed on the seven-segment digital tube
mov dptr,#numtab ;Specify the start address of the table lookup
mov r0,#4
dpl1: mov r1,#250 ;Display 1000 times
dplop: mov a,a_bit ;Get the value of the second digit
MOVC A,@A+DPTR ;Look up the 7-segment code of the second digit
mov p0,a ;Send to P0 port for display
clr p2.6 ;Open the unit digit display
acall d1ms ;Display 1ms
setb p2.6 ;Turn off the display
mov a,b_bit ;get the value of the 10-second bit
MOVC A,@A+DPTR ;check the 7-segment code of the 10-second bit
mov p0,a ;send the 10-second bit to port P0 for display
clr p2.5 ; open 10 seconds display
acall d1ms ; display 1ms
setb p2.5
mov a,c_bit ; get the bit position
MOVC A,@A+DPTR;
mov p0,a ;
clr p2.4 ;
acall d1ms ;
setb p2.4
mov a,d_bit ; take 10th bit
MOVC A,@A+DPTR ;
mov p0,a ;
clr p2.3 ;
acall d1ms ;
setb p2.3
mov a,e_bit ; get hour bit
MOVC A,@A+DPTR ;
mov p0,a ;
clr p2.2 ;
acall d1ms ;
setb p2.2
mov a,f_bit ; get 10 hours bit
MOVC A,@A+DPTR ;
mov p0,a ;
clr p2.1 ;
acall d1ms ;
setb p2.1
djnz r1,dplop ;100 endless loops
djnz r0,dpl1 ;4 100 endless loops
ret
D1MS: MOV R7,#20 ;1MS delay (calculated as 12MHZ)
DJNZ R7,$
RET
;Digital arrangement table of each stroke of the seven-segment digital tube - http://www.51hei.com/ provides
numtab: db 28h,7eh,0a2h,62h,74h,61h,21h,7ah,20h,60h
;0 1 2 3 4 5 6 7 8 9
end
Previous article:Design of MCU Cycle Light Assembly Program
Next article:Design of an indoor intelligent monitoring system
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
- Classification of RFID readers and their advantages
- [Repost] Correctly select low noise amplifier
- NTC thermistor driver for MicroPython
- How does Cyclone2's ep2c8 provide clock to external ADC?
- Comparison of Autoliv 2nd and 3rd generation night vision cameras
- If I use a battery to power a DCDC circuit, how can I be sure that the battery has enough power?
- Standard USB keyboard data packet
- 【Small home weather station】+ Hardware design, board proofing
- Forever power_A tiny device that turns your universal power bank into an uninterruptible power supply
- 【NUCLEO-WL55JC2 Review 2】Introduction to NUCLEO-WL55JC2 Development Board