5409 views|1 replies

1379

Posts

0

Resources
The OP

Schematic diagram and program for making electronic clock calendar [Copy link]

1. The power supply VCC is 5V, providing at least 200mA. (You can use a 3w6v transformer to rectify and filter, and then use 7805 to stabilize the voltage.)
2. J1 is the interface of the LCD screen. The LCD screen in the picture uses the HD61202 chip, 128*64 dot matrix. Netizens need to ask
the supplier for relevant information and interface definitions when purchasing. The interface definition of the LCD screen has been standardized, but the pin distribution may be
different , so you must pay attention to this. It would be best if you can test the quality of the LCD screen when purchasing.


The procedure is as follows:

time0 equ 32 ;53ms
time1 equ 187 ;10s
sel0 equ 0feh
;second low sel1 equ 0fdh ;second high
sel2 equ 0fbh ;minute low
sel3 equ 0f7h ;minute high
sel4 equ 0efh ;hour low
sel5 equ 0dfh ;hour high
sel6 equ 0bfh ;day low
sel7 equ 07fh ;day high
sel8 equ 0feh ;month low
sel9 equ 0fdh ;month high
sel10 equ 0fbh ;year low
sel11 equ 0f7h ;year high
selno equ 0ffh
;---------------------
outPort data p0
selPort0 data p2
selPort1 data p1

second0 data 08h
second1 data 09h
minute0 data 0ah
minute1 data 0bh
hour0 data 0ch
hour1 data 0dh date0
data 0eh
date1 data 0fh
month0 data 10h
month1 data 11h
year0 data 12h
year1 data 13h

solded data 30h ;led dynamic scan count
seldata data 31h ;select item when modifying
key0Data data 32h ;key status
key1Data data 33h
key2Data data 34h
key3Data data 35h
tims data 36h
tims0 data 37h
;---------------------
rst bit p3.0
io bit p3.1
sclk bit p3.2
key0Pin bit p1.4
key1Pin bit p1.5
key2Pin bit p1.6
key3Pin bit p1.7
;---------------------
chgMode bit 20h.0 ;modify status or normal status
sel0Dot bit 21h.0 ;decimal point status
sel1Dot bit 21h.1
sel2Dot bit 21h.2 sel3Dot
bit 21h.3 sel4Dot bit 21h.4 sel5Dot bit 21h.5 sel6Dot bit 21h.6 sel7Dot bit 21h.7 sel8Dot bit 22h.0 sel9Dot bit 22h.1 sel10Dot bit 22h.2 sel11Dot bit 22h.3 ;--------------------- org 0 ljmp main org 0bh ;---------------------------------------- tim0: mov th0,#0f2h ;24M-1666us,50Hz refresh rate mov tl0,#0fch ;3332 push acc push psw push 00h mov a,selled rl a jmp @a+dptr selLab: ajmp sel0do ajmp sel1do ajmp sel2do ajmp sel3do ajmp sel4do ajmp sel5do ajmp sel6do ajmp sel7do






























ajmp sel8do
ajmp sel9do
ajmp sel10do
;ajmp sel11do
sel11do:mov sold,#0ffh
mov c,sel11Dot
mov selPort1,#sel11
ajmp sel10a
sel0do: mov selPort0,#sel0
mov c,sel0Dot
ajmp sel7a
sel1do: mov selPort0,#sel1
mov c,sel1Dot
ajmp sel7a
sel2do: mov selPort0,#sel2
mov c,sel2Dot
ajmp sel7a
sel3do: mov selPort0,#sel3 mov
c,sel3Dot
ajmp sel7a
sel4do: mov selPort0,#sel4
mov c,sel4Dot
ajmp sel7a
sel5do: mov selPort0,#sel5
mov c,sel5Dot ajmp
sel7a
sel6do: mov selPort0,#sel6
mov c,sel6Dot
ajmp sel7a
sel7do: mov selPort0,#sel7
mov c,sel7Dot
sel7a: mov selPort1,#selno
ajmp _tim0a
sel8do: mov selPort1,#sel8
mov c,sel8Dot
ajmp sel10a
sel9do: mov selPort1,#sel9
mov c,sel9Dot
ajmp sel10a
sel10do:mov selPort1,#sel10
mov c,sel10Dot
sel10a: mov selPort0,#selno
;ajmp _tim0a
_tim0a:mov f0,c
mov a,selled
add a,#second0
mov r0,a
mov a,@r0
add a,#2
movc a,@a+pc
sjmp _tim0b
NUMLAB: ;Gongyangdb
0C0H ;NUM_0
db 0F9H ;NUM_1
db 0A4H ;
NUM_2
db 0B0H ;NUM_3 db
99H ;NUM_4
db 92H ;NUM_5 db 82H ;NUM_6
db 0F8H ;NUM_7
db 80H ;NUM_8
db 90H ;NUM_9
;db 88H ;NUM_A
;db 83H ;NUM_B
;db 0C6H ;NUM_C
;db 0A1H ;NUM_D
;db 86H ;NUM_E
;db 8EH ;NUM_F
_tim0b:mov c,f0
mov acc.7,c
mov outPort,a
inc sold

djnz tims,_tim0c
mov tims,#time0
acall read1302 ;Read 1302/53ms
jnb chgMode,_tim0c
djnz tims0,_tim0c
clr chgMode ;Modify mode end
mov a,#0ffh
mov 21h,a
mov 22h,a
_tim0c:mov a,tims
anl a,#7
jnz _tim0d
acall key0 ;Key scan
acall key1
acall key2
acall key3
_tim0d:pop 00h
pop psw
pop acc
reti
;---------------- --------------------------
main: mov sp,#3fh
mov tmod,#01h
setb tr0
mov ie,#82h
clr a
mov sold,a
mov seldata,a
mov 21h,a
mov 22h,a
clr chgMode
mov tims,#time0
mov dptr,#selLab
sjmp $
;------------------------ ----------------
_Key0Do: ;up
acall _keyIn
jnc _Key0Do0
ajmp inc_vale
_Key0Do0:
ret
;-------------------- --------------------
_Key1Do: ;down
acall _keyIn
jnc _Key0Do0
ajmp dec_vale
;----------------------------------------
_Key2Do: ;left
acall _keyIn
jnc _Key3Do0 ;Enter the modification mode for the first time, do not modify the content
inc seldata
mov a,seldata
cjne a,#6,_Key3Do0
clr a ;Seconds-0,Minutes-1,Hours-2,Days-3,Months-4,Years -5
sjmp _Key3Do2
;----------------------------------------
_Key3Do: ;right
acall _keyIn
jnc _Key3Do0 ;Enter the modification mode for the first time, do not modify the content
dec seldata
mov a,seldata
cjne a,#0ffh,_Key3Do0
mov a,#5 ;Seconds - 0,Minutes - 1,Hours - 2,Days - 3,Months -4,year-5
_Key3Do2:
mov seldata,a
_Key3Do0:
mov a,seldata
cjne a,#4,$+3
jnc _Key3Do1
mov 22h,#0ffh
mov 21h,#0fch
jz _Key3Do0a
mov b,a
mov a,21h
rl a
rl a
djnz b,$-2
mov 21h,a
_Key3Do0a:
ret
_Key3Do1:
clr acc.2 ;subb a,#4
mov 21h,#0ffh
mov 22h,#0fch
jz _Key3Do1a
mov b,a
mov a,22h
rl a
rl a
djnz b,$-2
mov 22h,a
_Key3Do1a:
ret
;----------------------------------------
_keyIn:
mov c,chgMode
jc _keyIn0
setb chgMode ;Enter modification mode for the first
time_keyIn0:mov tims0,#time1
ret
;--------------------------------- -------
read1302:
mov r1,#second1+1
mov b,#81h ;second
acall read1302a
mov b,#83h ;minute
acall read1302a
mov b,#85h ;hour
acall read1302a
mov b,#87h ;date
acall read1302a
mov b,#89h ;month
acall read1302a
mov b,#8dh ;year
acall read1302a
ret
;------------------ ---------------------
read1302a:
setb rst
mov a,b
acall wr_1302
acall rd_1302
clr rst
mov b,a
anl a,#0fh
dec r1
mov @r1,a
xch a,b
swap a
anl a,#07h
dec r1
mov @r1,a
ret
;------------------- --------
wr_cmd:
setb rst
push acc
mov a,b
acall wr_1302
pop acc
acall wr_1302
clr rst
ret
;---------------------- -----
wr_1302:
mov b,#8
wr_1302_0:
rrc a
mov io,c
setb sclk
sjmp $+2
clr sclk
djnz b,wr_1302_0
ret
;--------------------------
rd_1302 :
mov b,#8
rd_1302_0:
setb sclk
setb io
mov c,io
clr sclk
rrc a
djnz b,rd_1302_0
ret
;---------------------------
key0: jb Key0Pin,$+8
mov Key0Data,#0
sjmp $+21h ;No key pressed Next, jump
mov a,Key0Data
cjne a,#0c0h,$+3
jnc $+0dh
add a,#40h
mov Key0Data,a
cjne a,#0c0h,$+14
acall _Key0Do ; first
sjmp $+0fh
anl a ,#3fh
djnz acc,$+7 ; second 1.3s
acall _Key0Do
mov a,#10 ;Continue key, 200ms
orl a,#0c0h
mov Key0Data,a
ret
;----------------------------------------
key1: jb Key1Pin,$+8
mov Key1Data,#0
sjmp $+21h ;No key pressed, jump
mov a,Key1Data
cjne a,#0c0h,$+3
jnc $+0dh
add a,#40h
mov Key1Data,a
cjne a,#0c0h,$+14
acall _Key1Do ;First
sjmp $+0fh
anl a,#3fh
djnz acc,$+7 ;Second 1.3s
acall _Key1Do
mov a,#10 ;Continue key, 200ms
orl a,#0c0h
mov Key1Data,a
ret
;----------------------------------------
key2: jb Key2Pin,$+8
mov Key2Data,#0
sjmp $+21h ;No key pressed, jump
mov a,Key2Data
cjne a,#0c0h,$+3
jnc $+0dh
add a,#40h
mov Key2Data,a
cjne a,#0c0h,$+14
acall _Key2Do ;First time
sjmp $+0fh
anl a,#3fh
djnz acc,$+7 ;Second time 1.3s
acall _Key2Do
mov a,#10 ;Continuous key, 200ms
orl a,#0c0h
mov Key2Data,a
ret
;----------------------------------------
key3: jb Key3Pin,$+8
mov Key3Data,#0
sjmp $+21h ;No key pressed, jump
mov a,Key3Data
cjne a,#0c0h,$+3
jnc $+0dh
add a,#40h
mov Key3Data,a
cjne a,#0c0h,$+14
acall _Key3Do ;First time
sjmp $+0fh
anl a,#3fh
djnz acc,$+7 ;Second time 1.3s
acall _Key3Do
mov a,#10 ;Continuous key,200ms
orl a,#0c0h
mov Key3Data,a
ret
;---------------------------------Calculate
inc_vale:mov a,seldata
cjne a,#5,inc_vale_1
inc year0
mov a,year0
cjne a,#10,inc_vale_0a
mov year0,#0
inc year1
mov a,year1
cjne a,#10,inc_vale_0a
mov year1,#0
inc_vale_0a:
mov a,year1
swap a
orl a,year0
mov b,#8ch
acall wr_cmd
ajmp inc_vale_end
inc_vale_1:
cjne a,#4,inc_vale_2
mov a,month1
jnz inc_vale_1b
inc month0
mov a,month0
cjne a,#10,inc_vale_1a
mov month0,#0
mov month1,#1
ajmp inc_vale_1a
inc_vale_1b:
inc month0
mov a,month0
cjne a,#3,inc_vale_1a
mov month0,#1
mov month1,#0
inc_vale_1a:
mov a,month1
swap a
orl a,month0
mov b,#88h
acall wr_cmd
ajmp inc_vale_end
inc_vale_2:
cjne a,#3,inc_vale_3
mov a,date1
cjne a,#3,inc_vale_2b
inc date0
mov a,date0
cjne a,#2,inc_vale_2a
mov date0,#1
mov date1,#0
sjmp inc_vale_2a
inc_vale_2b:
inc date0
mov a,date0
cjne a,#10,inc_vale_2a
mov date0,#0
inc date1
inc_vale_2a:
mov a,date1
swap a
orl a,date0
mov b,#86h
acall wr_cmd
ajmp inc_vale_end
inc_vale_3:
cjne a,#2,inc_vale_4
mov a,hour1
cjne a, #2,inc_vale_3b
inc hour0
mov a,hour0
cjne a,#4,inc_vale_3a mov
hour0,#0
mov hour1,#0
ajmp inc_vale_3a
inc_vale_3b:
inc hour0
mov a,hour0
cjne a,#10,inc_vale_3a
mov hour0,#0
inc hour1
inc_vale_3a:
mov a,hour1
swap a
orl a,hour0
mov b,#84h
acall wr_cmd
ajmp inc_vale_end
inc_vale_4:
cjne a,#1,inc_vale_5
inc minute0
mov a,minute0
cjne a,#10,inc_vale_4a
mov minute0,#0
inc minute1
mov a,minute1
cjne a,#6,inc_vale_4a
mov minute1,#0
inc_vale_4a:
mov a,minute1
swap a
orl a,minute0
mov b,#82h
acall wr_cmd
ajmp inc_vale_end
inc_vale_5:
inc second0
mov a,second0
cjne a,#10,inc_vale_5a
mov second0,#0
inc second1
mov a,second1
cjne a,#6,inc_vale_5a
mov second1,#0
inc_vale_5a:
mov a,second1
swap a
orl a, second0
mov b,#80h
acall wr_cmd
inc_vale_end:
ret
;----------------------------------------- ------
dec_vale:mov a,seldata
cjne a,#5,dec_vale_1
dec year0
mov a,year0 cjne
a ,#0ffh,dec_vale_0 mov year0
,#9
dec year1
mov a,year1
cjne a,#0ffh,dec_vale_0
mov year1,#9
dec_vale_0:
ajmp inc_vale_0a
dec_vale_1:
cjne a,#4,dec_vale_2
dec month0
mov a,month0
jnz dec_vale_1a
mov a,month1
jnz dec_vale_1b
mov month0,#2
mov month1,#1
ajmp inc_vale_1a
dec_vale_1b:
dec month1
mov month0,#9
dec_vale_1a:
ajmp inc_vale_1a
dec_vale_2:
cj a,#3,dec_vale_3 mov
a,date1
jnz dec_vale_2b
dec date0
mov a,date0
cjne a,#0,dec_vale_2a
mov date0,#1
mov date1,#3
sjmp dec_vale_2a
dec_vale_2b:
dec date0
mov a,date0
cjne a,#0ffh ,dec_vale_2a
mov date0,#9
dec date1
dec_vale_2a:
ajmp inc_vale_2a
dec_vale_3:
cjne a,#2,dec_vale_4
dec hour0
mov a,hour0
cjne a,#0ffh,dec_vale_3a
mov hour0,#9
dec hour1
mov a,hour1
cjne a,#0ffh,dec_vale_3a
mov hour0,#3
mov hour1,#2
dec_vale_3a:
ajmp inc_vale_3a
dec_vale_4:
cjne a,#1,dec_vale_5
dec minute0
mov a,minute0
cjne a,#0ffh, dec_vlae_4a mov
minute0,#9
dec minute1
mov a,minute1
cjne a,#0ffh,dec_vlae_4a
mov minute1,#5
dec_vlae_4a:
ajmp inc_vale_4a
dec_vale_5:
inc second0
mov a,second0
cjne a,# 0ffh,dec_vlae_5a
mov second0,#9
dec second1
mov a,second1
cjne a,#0ffh,dec_vlae_5a
mov second1,#5
dec_vlae_5a:
ajmp inc_vale_5a
;----------------------------- ---------------
; Note: This program was made by netizen slaoliu, and has not been tested and debugged. If there are any errors, please correct them.
; LED display distribution:
; Year (high and low) Month (high and low) Day (high and low) Hour (high and low) Minute (high and low) Second (high and low)
; sl11 sl10 sl9 sl8 sl7 sl6 sl5 sl4 sl3 sl2 sl1 sl0
; Normal state: decimal point is not displayed.
; Modification state: decimal point display is being modified
;key0: The modified data increases. ;
key1: The modified data decreases.
;key2: Loop left to select the item to be modified.
;key3: Right cycle to select the item to be modified.

This post is from MCU

Latest reply

: Cycle left to select the items to be modified. ;key3: Cycle right to select the items to be modified.  Details Published on 2009-10-26 17:19

175

Posts

0

Resources
2
: Cycle left to select the items to be modified. ;key3: Cycle right to select the items to be modified.
This post is from MCU

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

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