4084 views|0 replies

1379

Posts

0

Resources
The OP
 

Two-digit automatic adding counter [Copy link]

Hardware settings as b.htm test

a_bit equ 20h ; storage place for units digit
b_bit equ 21h ; storage place for tens digit
temp equ 22h ; counter register

star: mov temp,#0 ; initialize counter
stlop: acall display
inc temp
mov a,temp
cjne a,#100,next ;=100 again
mov temp,#0
next: ljmp stlop

; 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 ; tens digit is in a
mov a_bit,b ; units digit is in b

mov dptr,#numtab ; specify the starting address of table lookup
mov r0,#4
dpl1: mov r1,#250 ; display 1000 times
dplop: mov a,a_bit ; get units digit
MOVC A,@A+DPTR ;Check the 7-segment code of the ones digit
mov p0,a ;Send the 7-segment code of the ones digit
clr p2.0 ;Open the ones digit and display
acall d200us ;Display 200us
setb p2.0
mov a,b_bit ;Get the tens digit
MOVC A,@A+DPTR ;Check the 7-segment code of the tens digit
mov p0,a ;Send the 7-segment code of the tens digit
clr p2.1 ;Open the tens digit and display
acall d200us ;Display 200us
setb p2.1
djnz r1,dplop ;100 endless loops
djnz r0,dpl1 ;4 endless loops of 100 times
ret
;200uS delay (calculated according to 12MHZ)
;=========================================================
D200uS: MOV R7,#98
DJNZ R7,$
nop
RET

;7-segment digital tube digital arrangement table
numtab: db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
;0 1 2 3 4 5 6 7 8 9
db 88h,83h,0c6h,0a1h,86h,8eh
;abcdef


end

This post is from MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list