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

📄 hh.asm

📁 温度传感器DS18B20操作源程序
💻 ASM
字号:
                org     00000h
                ljmp    start
                org     00050h
         start:
                mov     sp,#0b0h
                mov     scon,#00000000b
                mov     p3,#0ffh

                mov     r0,#0ffh
     _wait40ms: nop
               ; mov     b,#500                       ?b=255
                djnz    b,$
                djnz    r0,_wait40ms

                mov     p3,#0ffh
                mov     a,#00110000b    ; Function Set: DL
                lcall   wrt_cmd

                mov     a,#00110000b    ; Function Set: RE
                lcall   wrt_cmd

                mov     a,#00001110b    ; Display ON
                lcall   wrt_cmd

                mov     a,#00000001b    ; Clear display
                lcall   wrt_cmd

                mov     r1,#0ffh
     _wait10ms: nop
                mov     b,#0ffh
                djnz    b,$
                djnz    r1,_wait10ms

                mov     a,#00000110b    ; Mode Set
                lcall   wrt_cmd

                mov     a,#0c4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0cfh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0a9h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0fch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0c7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0f8h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0dch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d2h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bdh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bah         ; Write a byte
                lcall   wrt_byte

                mov     a,#090h         ; return to line 2
                lcall   wrt_cmd

                mov     a,#0c4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0cfh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0a9h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0fch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0c7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0f8h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0dch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d2h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bdh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bah         ; Write a byte
                lcall   wrt_byte

                mov     a,#088h         ; return to line 3
                lcall   wrt_cmd

                mov     a,#0c4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0cfh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0a9h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0fch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0c7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0f8h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0dch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d2h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bdh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bah         ; Write a byte
                lcall   wrt_byte

                mov     a,#098h         ; return to line 4
                lcall   wrt_cmd

                mov     a,#0c4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0cfh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0a9h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0beh         ; Write a byte
                lcall   wrt_byte
                mov     a,#0fch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0c7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0f8h         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d7h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0dch         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d2h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bdh         ; Write a byte
                lcall   wrt_byte

                mov     a,#0d4h         ; Write a byte
                lcall   wrt_byte
                mov     a,#0bah         ; Write a byte
                lcall   wrt_byte

                ljmp    $
                ljmp    $
;..................................................................
       wrt_cmd: nop
                push    b
                push    dpl

                clr     c
;                mov     dpl,a
                mov     b,#8
   _wrt_cmd_lp: clr     c
                rlc     a
                xch     a,dpl
                rrc     a
                xch     a,dpl
                djnz    b,_wrt_cmd_lp

                clr     ti
                mov     sbuf,#00011111b
                jnb     ti,$
                clr     ti
                mov     a,dpl
                anl     a,#00fh
                mov     sbuf,a
                jnb     ti,$
                clr     ti
                mov     a,dpl
                swap    a
                anl     a,#00fh
                mov     sbuf,a
                jnb     ti,$
                clr     ti
                mov     b,#0ffh
                djnz    b,$

                pop     dpl
                pop     b
                ret
;..................................................................
      wrt_byte: nop
                push    b
                push    dpl

                clr     c
                mov     dpl,a
                mov     b,#8
  _wrt_byte_lp: clr     c
                rlc     a
                xch     a,dpl
                rrc     a
                xch     a,dpl
                djnz    b,_wrt_byte_lp

                clr     ti
                mov     sbuf,#01011111b
                jnb     ti,$
                clr     ti
                mov     a,dpl
                anl     a,#00fh
                mov     sbuf,a
                jnb     ti,$
                clr     ti
                mov     a,dpl
                swap    a
                anl     a,#00fh
                mov     sbuf,a
                jnb     ti,$
                clr     ti
                mov     b,#0ffh
                djnz    b,$

                pop     dpl
                pop     b
                ret
;--------------------------------------------------------------------
                end

⌨️ 快捷键说明

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