本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
初学单片机不久,都是拿来主义,自己做了个89S52+1302的时钟,感觉不错,发来给大家看看。
同时有个小问题求助各位大侠:就是24C02保存数字的问题。我用K1选择数码管并让选中的闪动,用K2调节数字从0到9变化,8个数码管调好后按K3键保存,使得在下次开机时能够显示这次调好的数字。
8个数码管调节数字的程序如下:
d1 bit p2.0 ;定义各参数
d2 bit p2.1
d3 bit p2.2
d4 bit p2.3
d5 bit p2.4
d6 bit p2.5
d7 bit p2.6
d8 bit p2.7
k1 bit p1.5
k2 bit p1.6
k3 bit p1.7 ;用来保存调好的数字
scl bit p3.6
sda bit p3.7
s1 equ 31h
s2 equ 32h
s3 equ 33h
s4 equ 34h
s5 equ 35h
s6 equ 36h
s7 equ 37h
s8 equ 38h
n1 equ 21h
n2 equ 22h
n3 equ 23h
n4 equ 24h
n5 equ 25h
n6 equ 26h
n7 equ 27h
n8 equ 28h
org 0000h
ljmp main
org 0bh
ljmp timer0
org 20h
main:mov r0,#30h
clear:
inc r0
mov @r0,#10
cjne r0,#38h,clear
setb k1
setb k2
setb k3
setb ea
setb et0
setb tr0
mov dptr,#numtab
lcall convert
clr a
loop:
lcall display
jnb k1,key1
jnb k2,key2
sjmp loop
key1:inc acc
cjne a ,#9,k1end
mov acc ,#0
k1end:mov 30h,#0ffh
m2:acall display
djnz 30h,m2
sjmp loop
key2:
cjne a ,#1,k21
inc s1
mov r2,s1
cjne r2,#12,k2end
mov s1,#0
k21:cjne a ,#2,k22
inc s2
mov r2,s2
cjne r2,#12,k2end
mov s2,#0
k22:cjne a ,#3,k23
inc s3
mov r2,s3
cjne r2,#12,k2end
mov s3,#0
k23:cjne a ,#4,k24
inc s4
mov r2,s4
cjne r2,#12,k2end
mov s4,#0
k24:cjne a ,#5,k25
inc s5
mov r2,s5
cjne r2,#12,k2end
mov s5,#0
k25:cjne a ,#6,k26
inc s6
mov r2,s6
cjne r2,#12,k2end
mov s6,#0
k26:cjne a ,#7,k27
inc s7
mov r2,s7
cjne r2,#12,k2end
mov s7,#0
k27:cjne a ,#8,k2end
inc s8
mov r2,s8
cjne r2,#12,k2end
mov s8,#0
k2end:mov 30h,#0ffh
m1:
acall display
djnz 30h,m1
ljmp loop
timer0:
push acc
inc 29h
mov a ,29h
cjne a ,#50,exit
mov 29h,#0
cpl f0
exit:pop acc
reti
display:
lcall convert
jb f0,noflash
push acc
add a ,#20h
mov r0,a
mov @r0,#0ffh
pop acc
noflash:
mov p0,n8
clr d8
acall delay
setb d8
mov p0,n7
clr d7
acall delay
setb d7
mov p0,n6
clr d6
acall delay
setb d6
mov p0,n5
clr d5
acall delay
setb d5
mov p0,n4
clr d4
acall delay
setb d4
mov p0,n3
clr d3
acall delay
setb d3
mov p0,n2
clr d2
acall delay
setb d2
mov p0,n1
clr d1
acall delay
setb d1
ret
delay:
mov 20h,#30h
djnz 20h,$
ret
convert:
push acc
mov a ,s1
movc a ,@a+dptr
mov n1,a
mov a ,s2
movc a ,@a+dptr
mov n2,a
mov a ,s3
movc a ,@a+dptr
mov n3,a
mov a ,s4
movc a ,@a+dptr
mov n4,a
mov a ,s5
movc a ,@a+dptr
mov n5,a
mov a ,s6
movc a ,@a+dptr
mov n6,a
mov a ,s7
movc a ,@a+dptr
mov n7,a
mov a ,s8
movc a ,@a+dptr
mov n8,a
pop acc
ret
numtab:db 28h,7eh,0a2h,62h,74h,61h,21h,7ah,20h,60h,0f7h,0ffh
end
请教各位大侠,怎么样才能保存我想要的数字呢?谢谢了!
|
|