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

📄 ds1620.asm

📁 DS1620/display for 8051
💻 ASM
📖 第 1 页 / 共 2 页
字号:
                add     a,#1            ; mimute add 1
                da      a               ; decimal adjust
                mov     minute,a
                xrl     a,#60h          ; compare mintute equ 60
                jnz     ctc0_ret        ; if not jmp return
                mov     minute,#0       ; if yet clear it
                mov     a,hour
                add     a,#1            ; hour add 1
                da      a               ; decimal adjust
                mov     hour,a
                xrl     a,#23h          ; compare hour equ 23
                jnz     ctc0_ret        ; if not jmp return
                mov     hour,#0         ; if yet clear it
ctc0_ret:       pop     dpl
                pop     dph
                pop     a               ; reload accumulator
                pop     psw             ; reload program status word
                reti

lcd_hex_asc:    push    a
		swap	a
                call    hex_asc
                mov     r3,a
                call    mlcd_data
		pop	a
		push	a
                call    hex_asc
                mov     r3,a
                call    mlcd_data
		pop	a
		ret

;*********************************************
;*                                           *
;*  subroutine : send out the current time.  *
;*                                           *
;*********************************************

send_time:      mov     a,#pageaddr
                clr     lcda0
                call    pw2
                mov     a, #hcoladdr
                acall   pw2
                mov     a, #lcoladdr
                acall   pw2
                mov     a,hour
                call    lcd_hex_asc
                mov     r3,#':'
                call    mlcd_data
                mov     a,minute
                call    lcd_hex_asc
                mov     r3,#':'
                call    mlcd_data
                mov     a,second
                call    lcd_hex_asc
                ret

main:           call    lcd_lf
                setb    rrst                    ; to start communication
                setb    rrst

                mov     cmd,#eeh
                call    out_cmd
                clr     rrst
                setb    rrst

                mov     cmd,#0ch                ; write 0ch to 1620 to start config writing protecol
                call    out_cmd

                mov     cmd,#02h                ; write config byte 02h to initilize 1620
                call    out_cmd
                clr     rrst

main_loop:      setb    rrst
                mov     cmd,#aah                ; out cmd aah to start temp. reading protocol
                call    out_cmd

                setb    ddq
                call    get_temperature
                clr     rrst
                mov     a,temperaturel
                clr     c
                rrc     a                       ; divide 2
                mov     buffer,a
                jnc     main2

main2:          mov     a,#pageaddr+1
                clr     lcda0
                call    pw2

                mov     a,buffer
                call    hex2bcd
                mov     r3,a
                ;call    lcd_data
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                call    lcd_hex_asc
                ;mov     a,r3
                ;call    send_data
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                mov     reading,a
                mov     r3,#'C'
                call    mlcd_data
                call    lcd_lf
                mov     a,#pageaddr+2
                call    pw2

;************************************************************

check_hi:       clr     c
                mov     a,buffer
                cjne    a,hi,print_high

hi_carry:       mov     a,buffer
                call    hex2bcd
                call    lcd_hex_asc
                mov     hi,buffer
                jmp     check_lo

print_high:     jnc     hi_carry
                mov     a,hi
                call    hex2bcd
                call    lcd_hex_asc

check_lo:       mov     a,#pageaddr+3
                clr     lcda0
                call    pw2
                call    lcd_lf

                mov     a,buffer
                cjne    a,lo,print_low
lo_carry:       mov     a,buffer
                call    hex2bcd
                call    lcd_hex_asc
                mov     lo,buffer
                jmp     check_exit

print_low:      jc      lo_carry
                mov     a,lo
                call    hex2bcd
                call    lcd_hex_asc
                mov     a,lo
                jnz     check_exit
                mov     lo,buffer

check_exit      ret

hex2bcd:        mov     b,#10                    ; a is hex data
                div     ab                       ; divide a by b
                rl      a
                rl      a
                rl      a
                rl      a
                anl     a,#0f0h
                anl     b,#00fh
                orl     a,b
                ret
;************************************************************************
;*                                                                      *
;*  subroutine : out command to ds1260                                  *
;*                                                                      *
;************************************************************************
                
out_cmd:        mov     b,#8                    ; loop count
out_cmd1:       mov     a,cmd                   ; cmd(command for 1620) in register
                anl     a,#1                    ;
                jz      out_cmd2
                clr     cclk
                setb    ddq
                setb    cclk
                jmp     out_cmd3

out_cmd2:       clr     cclk
                clr     ddq
                setb    cclk
out_cmd3:       mov     a,cmd                   ; rotate cmd register
                rr      a
                mov     cmd,a
                dec     b
                mov     a,b
                xrl     a,#0                    ; is done of the loop count?
                jnz     out_cmd1
                ret
get_temperature:
                mov     b,#8                    ; count for data input time
get_temp1:      clr     cclk
                mov     c,ddq
                mov     acc.0,c
                mov     c,cclk
                mov     acc.1,c
                mov     c,rrst
                mov     acc.2,c
                call    shift_data2reg
                setb    cclk
                dec     b
                mov     a,b
                xrl     a,#0
                jnz     get_temp1                ; this loop can get bit 0..7 only.
                clr     cclk

                mov     c,ddq
                mov     acc.0,c

                mov     c,cclk
                mov     acc.1,c

                mov     c,rrst
                mov     acc.2,c

                rrc     a
                setb    cclk
                mov     a,temperatureh
                rlc     a                        ; c -> bit0 of temp. upper byte
                mov     temperatureh,a           ; to temperature of high byte
                anl     temperatureh,#1          ; bit 0 is vaild only
                setb    cclk
                ret

shift_data2reg: rrc     a                        ; bit0 of accumulator -> c
                mov     a, temperaturel          ;
                rrc     a                        ; c->7..0->c
                mov     temperaturel,a
                ret

;* note: this chars. have be modify , not for use at normal display.
word_data:
                db      00h,00h,00h,00h,00h,00h     ;   #20h
                db      ffh,ffh,ffh,00h,00h,00h     ;!  #21h
                db      ffh,ffh,ffh,ffh,ffh,ffh     ;"  #22h
                db      14h,7fh,14h,7fh,14h,00h     ;#
                db      08h,1ch,3eh,7fh,1ch,1ch     ;<-     ;don' use
;                db      24h,2ah,6bh,2ah,12h,00h     ;$
                db      23h,13h,08h,64h,62h,00h     ;%
                db      1ch,1ch,1ch,1ch,1ch,00h     ;&      ;don't use
                db      ffh,ffh,ffh,ffh,ffh,00h     ;'      ;note
                db      00h,1ch,22h,41h,00h,00h     ;(
                db      00h,41h,22h,1ch,00h,00h     ;)
                db      14h,08h,3eh,08h,14h,00h     ;*
                db      08h,08h,3eh,08h,08h,00h     ;+
                db      00h,50h,30h,00h,00h,00h     ;,
                db      08h,08h,08h,08h,08h,00h     ;-
                db      00h,60h,60h,00h,00h,00h     ;.
                db      20h,10h,08h,04h,02h,00h     ;/
                db      3eh,51h,49h,45h,3eh,00h     ;0
                db      00h,42h,7fh,40h,00h,00h     ;1
                db      42h,61h,51h,49h,46h,00h     ;2
                db      21h,41h,45h,4bh,31h,00h     ;3
                db      18h,14h,12h,7fh,10h,00h     ;4
                db      27h,45h,45h,45h,39h,00h     ;5
                db      3ch,4ah,49h,49h,30h,00h     ;6
                db      01h,01h,79h,05h,03h,00h     ;7
                db      36h,49h,49h,49h,36h,00h     ;8
                db      06h,49h,49h,29h,1eh,00h     ;9
                db      00h,36h,36h,00h,00h,00h     ;:
                db      00h,56h,36h,00h,00h,00h     ;;
                db      08h,14h,22h,41h,00h,00h     ;<
                db      14h,14h,14h,14h,14h,00h     ;=
                db      00h,41h,22h,14h,08h,00h     ;>
                db      02h,01h,51h,09h,06h,00h     ;?
                db      32h,49h,79h,41h,3eh,00h     ;@
                db      7eh,11h,11h,11h,7eh,00h     ;A
                db      7fh,49h,49h,49h,36h,00h     ;B
                db      3eh,41h,41h,41h,22h,00h     ;C
                db      7fh,41h,41h,41h,3eh,00h     ;D
                db      7fh,49h,49h,49h,41h,00h     ;E
                db      7fh,09h,09h,09h,01h,00h     ;F
                db      3eh,41h,41h,49h,3ah,00h     ;G
                db      7fh,08h,08h,08h,7fh,00h     ;H
                db      00h,41h,7fh,41h,00h,00h     ;I
                db      20h,40h,41h,3fh,01h,00h     ;J
                db      7fh,08h,14h,22h,41h,00h     ;K
                db      7fh,40h,40h,40h,40h,00h     ;L
                db      7fh,02h,0ch,02h,7fh,00h     ;M
                db      7fh,04h,08h,10h,7fh,00h     ;N
                db      3eh,41h,41h,41h,3eh,00h     ;O
                db      7fh,09h,09h,09h,06h,00h     ;P
                db      3eh,41h,51h,21h,5eh,00h     ;Q
                db      7fh,09h,19h,29h,46h,00h     ;R
                db      46h,49h,49h,49h,31h,00h     ;S
                db      01h,01h,7fh,01h,01h,00h     ;T
                db      3fh,40h,40h,40h,3fh,00h     ;U
                db      1fh,20h,40h,20h,1fh,00h     ;V
                db      3fh,40h,38h,40h,3fh,00h     ;W
                db      63h,14h,08h,14h,63h,00h     ;X
                db      01h,02h,7ch,02h,01h,00h     ;Y
                db      61h,51h,49h,45h,43h,00h     ;Z
                db      00h,7fh,41h,41h,00h,00h     ;[
                db      00h,00h,00h,00h,00h,00h     ;
                db      00h,41h,41h,7fh,00h,00h     ;]
                db      00h,02h,01h,02h,00h,00h     ;^
                db      40h,40h,40h,40h,40h,00h     ;_
                db      00h,01h,02h,04h,00h,00h     ;`
                db      20h,54h,54h,54h,78h,00h     ;a
                db      7fh,48h,44h,44h,38h,00h     ;b
                db      38h,44h,44h,44h,20h,00h     ;c
                db      38h,44h,44h,48h,7fh,00h     ;d
                db      38h,54h,54h,54h,18h,00h     ;e
                db      08h,7eh,09h,01h,02h,00h     ;f
                db      0ch,52h,52h,52h,3eh,00h     ;g
                db      7fh,08h,04h,04h,78h,00h     ;h
                db      00h,44h,7dh,40h,00h,00h     ;i
                db      20h,40h,44h,3dh,00h,00h     ;j
                db      7fh,10h,28h,44h,00h,00h     ;k
                db      00h,41h,7fh,40h,00h,00h     ;l
                db      7ch,04h,18h,04h,78h,00h     ;m
                db      7ch,08h,04h,04h,78h,00h     ;n
                db      38h,44h,44h,44h,38h,00h     ;o
                db      7ch,14h,14h,14h,08h,00h     ;p
                db      08h,14h,14h,18h,7ch,00h     ;q
                db      7ch,08h,04h,04h,08h,00h     ;r
                db      08h,54h,54h,54h,20h,00h     ;s
                db      04h,3fh,44h,40h,20h,00h     ;t
                db      3ch,40h,40h,20h,7ch,00h     ;u
                db      1ch,20h,40h,20h,1ch,00h     ;v
                db      3ch,40h,30h,40h,3ch,00h     ;w
                db      44h,28h,10h,28h,44h,00h     ;x
                db      0ch,50h,50h,50h,3ch,00h     ;y
                db      44h,64h,54h,4ch,44h,00h     ;z
;                db      00h,08h,36h,41h,00h,00h     ;{
;                db      00h,00h,7fh,00h,00h,00h     ;|
;                db      00h,41h,36h,08h,00h,00h     ;}
;                db      08h,08h,2ah,1ch,08h,00h     ;->
;                db      08h,1ch,2ah,08h,08h,00h     ;<-
;                db      00h,00h,00h,00h,00h,00h     ;
lcd_lf:         clr     lcda0
                mov     a, #hcoladdr
                acall   pw2
                mov     a, #lcoladdr
                acall   pw2
                ret

                end

⌨️ 快捷键说明

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