⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctrol_clk.asm

📁 数字锁相环程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
            
            mrw# @hl,data0
            mrw# @hl,data1
            mrw# @hl,data2
            mrw# @hl,data3
            
            mrw# @hl,scan_tl
            mrw# @hl,scan_th
            
            mrw# @hl,disp0  
            mrw# @hl,disp1
            mrw# @hl,disp2
            mrw# @hl,disp3
           
            lda store_up_t           
            sta draw_out_t
            eor freq0
            jnz store_end
            lds store_up_t,00h
            lds mem_full,01h
store_end:            
            jmp key0
;*****************************************
draw_out:
            lda draw_out_t
            jz draw_end 
            sta 75h
            call select_num
            mvl memory0
            mvh memory1
            mvu memory2
            
            mwr# data0,@hl
            mwr# data1,@hl
            mwr# data2,@hl
            mwr# data3,@hl
            
            mwr# scan_tl,@hl
            mwr# scan_th,@hl
            
            mwr# disp0,@hl  
            mwr# disp1,@hl
            mwr# disp2,@hl
            mwr# disp3,@hl
            
            call clk_ini
            call latch_ram
            call data_clk
            call display
            
            dec* draw_out_t
            jnz draw_end
            lda mem_full
            jz draw_out0
            lds draw_out_t,06h
            jmp draw_end
draw_out0:
            lda store_up_t
            sta draw_out_t
draw_end:
            jmp key0 
;*****************************************
select_num:
            dec* 75h
            jz sele_num0
            dec* 75h
            jz sele_num1
            dec* 75h
            jz sele_num2
            dec* 75h
            jz sele_num3
            dec* 75h
            jz sele_num4
            lds memory0,02h
            lds memory1,0bh
            jmp sele_end
sele_num0:
            lds memory0,00h
            lds memory1,08h
            jmp sele_end  
sele_num1:
            lds memory0,0ah
            lds memory1,08h
            jmp sele_end 
sele_num2:
            lds memory0,04h
            lds memory1,09h
            jmp sele_end                                 
sele_num3:
            lds memory0,0eh
            lds memory1,09h
            jmp sele_end 
sele_num4:
            lds memory0,08h
            lds memory1,0ah
sele_end:
            rts                                      
                                                                                    
;*****************************************
time_key:   
            lds  dis_time_f0,01h   
            call clear_lcd
            call disp_time 
t_key0:            
            lds key_signal,01h 
t_key1:     
            ;call disp_time
            slow    
            opb  key_signal
            ;mrw 74h,key_signal
            ;lcp 07h,04h
            ipc 74h
            jb2 ioc1_t_keys
            jb1 ioc0_t_keys
            sl0 key_signal
            jb3 t_key0 
            jmp t_key1
;*****************************************
ioc0_t_keys:
            call delay4
            lda key_signal
            jb0 fback_dts
            jb1 update_up
            jb2 update_dn
            jmp t_key1 
ioc1_t_keys:
            call delay4 
            lda key_signal
            jb0 modify_time
            jb1 modify_ok
            jmp t_key1  
;*****************************************
fback_dts:  
            
            lda set_time0
            jnz  dts_end 
            ;call clk_ini
            ;call latch_ram
            ;call data_clk
            call clear_lcd
            call display
            jmp  keyscan
dts_end:
            jmp t_key0              
;*****************************************
update_up:
             ; lds dis_time_f1,01h  
              lda set_time0
              jz update_up_end 
              lda set_time1
              jb0 up_hour
           
              inc* t_minute0
              daa* t_minute0
              jnc  update_up_end
              inc* t_minute1
              lds 74h,06h
              eor t_minute1
              jnz  update_up_end
              lds t_minute1,00h
update_up_end:
              call disp_time            
              jmp t_key1
up_hour:           
              inc* t_hour0
              daa* t_hour0
              jnc up_hour0
              inc* t_hour1
up_hour0:          
              lds 74h,04h
              eor t_hour0 
              jnz update_up_end
              lds 74h,02h
              eor t_hour1
              jnz update_up_end
              lds t_hour0,00h
              lds t_hour1,00h
              jmp update_up_end 
;*****************************************
update_dn:
              ;lds dis_time_f1,01h
              lda set_time0
              jz update_dn_end 
              lda set_time1
              jb0 dn_hour
              
              dec* t_minute0
              jc update_dn_end
              lds t_minute0,09h
              dec* t_minute1
              jc update_dn_end
              lds t_minute1,05h
update_dn_end:               
              call disp_time
              jmp t_key1 
dn_hour:
              dec*  t_hour0
              jc update_dn_end
              lda t_hour1
              jz dn_hour0
              lds t_hour0,09h
              dec* t_hour1
              jmp update_dn_end
dn_hour0:
              lds t_hour0,03h
              lds t_hour1,02h
              jmp update_dn_end                           
;*****************************************
modify_time:
            
            lds set_time0,01h
            inc* set_time1 
            jmp t_key0
;*****************************************
modify_ok: 
           lda set_time0
           jz  modify_end
           ;plc  08h
           ;sie* 08h
           lds dis_time_f1,00h
           lds half_sec,00h 
           lds set_time0,00h
           lds set_time1,00h
           lds t_sec0,00h
           lds t_sec1,00h
modify_end:                      
           jmp t_key0
;*****************************************
;*************lcd display ****************
display:                               ;1.83ms
           lds 74h,00h
           lcp 01h,04h
           mvh addr_l
           mvu addr_l
           mvl disp0
           lcd 02h,@hl
           mvl disp1
           lcd 03h,@hl
           mvl disp2
           lcd 04h,@hl
           lda disp3
           jnz dis0
           lds 74h,01h
           lcp 05h,04h
           jmp dis_end
dis0:           
           lds 74h,03h
           lcp 05h,04h
           nop          
dis_end:   
           lds dis_d_flag,01h         
           rts
           
;*****************************************
dis_ad:                               ;1.83ms
           lda dis_ad_flag
           jz dis1
           lda dis_d_flag 
           sub* disp0
           jc dis_ad_end
           lds disp0,09h
           dec* disp1
           jc dis_ad_end
           lds disp1,09h
           dec* disp2
           jc dis_ad_end
           lds disp2,09h
           dec* disp3
           jmp dis_ad_end
dis1:    
           lda dis_d_flag
           add* disp0
           daa* disp0
           jnc dis_ad_end
           inc* disp1
           daa* disp1
           jnc dis_ad_end
           inc* disp2
           daa* disp2
           jnc dis_ad_end
           inc* disp3 
           nop
dis_ad_end:
           rts   
;*****************************************
second_add:
           maf reg_cf
           plc  08h
           sie* 08h
           lda set_time0
           jnz second_end1
           
           inc* half_sec
           jb0 second_end3
                
           inc* t_sec0
           daa* t_sec0
           jnc second_end3
           inc* t_sec1
           lds 74h,06h
           eor t_sec1
           jnz second_end3
           lds t_sec1,00h
           
           inc* t_minute0
           daa* t_minute0
           jnc second_end3
           inc* t_minute1
           lds 74h,06h
           eor t_minute1
           jnz second_end3
           lds t_minute1,00h
           
           inc* t_hour0
           daa* t_hour0
           jnc second_a0
           inc* t_hour1
           
second_a0:           
           lds 74h,04h
           eor t_hour0 
           jnz second_end3
           lds 74h,02h
           eor t_hour1
           jnz second_end3
           lds t_hour0,00h
           lds t_hour1,00h
second_end3:           
           lda dis_time_f0
           jz  second_end
second_end2:           
           call disp_time 
second_end:
           mra reg_cf
           lda check_csf
           jb0 f_csf
           slow
f_csf:                     
           lda reg_ac
           rts
second_end1:
            ipc  74h
            jb1  check_touch
second_end4:            
            inc* dis_time_f1
            lda  set_time1
            jb0  show_hour
            lda  dis_time_f1
            jb0  second_end2
            lds  77h,00h
            lcp  01h,07h
            lcp  02h,07h
            ;lds  77h,01h
            ;lcp  05h,07h
            jmp  second_end
show_hour:
            lda  dis_time_f1
            jb0  second_end2
            lds  77h,00h
            lcp  03h,07h
            lcp  04h,07h
            ;lds  77h,01h
            ;lcp  05h,07h
            jmp  second_end            
check_touch:
            lda  key_signal
            jb0  second_end4
            jmp  second_end                        
;*****************************************
disp_time: 
           mvh addr_l
           mvu addr_l
           mvl t_minute0
           lcd 01h,@hl
           mvl t_minute1
           lcd 02h,@hl
           mvl t_hour0
           lcd 03h,@hl
           mvl t_hour1
           lcd 04h,@hl
           lda half_sec
           jb0 disp_t0
           lds 74h,00h
           lcp 05h,04h
           jmp disp_tend
disp_t0:
           lds 74h,01h
           lcp 05h,04h                    
disp_tend:   
                  
           rts
;*****************************************
disp_set_time:
               lda set_time0
               jz stime_end0 
               
               lda set_time1
               jb0 dis_hour
               lds 74h,00h
               lcp 01h,04h
               lcp 02h,04h
               jmp stime_end
dis_hour:
               lds 74h,00h   
               lcp 03h,04h
               lcp 04h,04h
stime_end:
               call delay0
stime_end0:                             
               rts                                                                                       
;*****************************************
latch_d:                             ; 51.2 ms   
           lds 75h,05h
latch_d0:        
           ipc 74h
           jb3 latch_d1
           jmp lat_delay
latch_d1:  
           call delay5
           dec* 75h
           jnz latch_d0
           lds f_back,01h
           jmp latch_end
lat_delay: 
           nop
           nop                      
           call delay5
           dec* 75h
           jnz lat_delay
           lds f_back,00h
latch_end:
           rts           
                                                           
;*****************************************
;*********delay=
delay0:
         plc 02h
         she 02h
         tmsx 110000111b
         halt
rts                           
;*********************************
;*********delay=216.32 us ********
delay1:
       call delay2
       nop
       nop
       nop
       nop
       nop
       nop
       nop
       nop
       nop
      ; ori* 00h,04h
      ; lcp 00h,00h
       rts 
;**********************************
;****** delay=3.36*a(b+1)+2.24 us 
delay2:
       lds  75h,05h ;a
del1:
       lds  74h,0bh ;b
del0:
       nop
       dec* 74h
       jnz  del0                      
       dec* 75h
       jnz  del1 
       rts      
;***********************************
;*********** delay=80ms **************
delay3:
       
       plc 02h
       she 02h
       tmsx 101010100b
       halt
       rts 
;***********************************
;*********** delay=438ms ***********
delay4:
       plc 02h
       she 02h
       tmsx 110000101b
       halt
       rts
;***********************************
;*********** delay=9.52ms ***********       
delay5:
       plc 02h
       she 02h
       tmsx 100001001b
       halt
       nop
       rts
;***********************************
;*********** delay=15 ms ***********       
delay6:
       plc 02h
       she 02h
       tmsx 100001111b
       halt
       rts       
.endc

.table
DATA    00H,bfh	
DATA    01H,86H	
DATA    02H,dbh	
DATA    03H,cfh	
DATA    04H,e6h
DATA    05H,edh
DATA    06H,fdh
DATA    07H,a7h
DATA    08H,ffh
DATA    09H,efh
.endt

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -