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

📄 dmxin.asm

📁 是一个接收程序
💻 ASM
字号:
;         dmx512 input
;         the b=25000hz
;         system clk =24m
;         smod=1
;value define
status2                   equ    20h
runbf                     bit    20h.0
fristaddallzorebf         bit    20h.4
lightadddobf              bit    20h.5
dmxoverend                bit    20h.6
allzorebf                 bit    20h.7
dmxinputbuff              equ    30h



;local
;   本机地止码
locallightrecodehigh           equ    31h   ; the light recode address high   ;-1
locallightrecodelow            equ    32h   ; the light recode address low      the recode max is 512
;   DMX 接收计数器
dmxchannelcounthigh       equ    33h   ; dmx input count  high
dmxchannelcountlow        equ    34h   ; dmx input count low      ;-1
;   通道数
lightchannelhigh          equ    35h    ;  +1
lightchannellow           equ    36h
;   数据保存指针
dmxdatastorehigh          equ    37h
dmxdatastorelow           equ    38h      ;+1


tempreg                   equ    39h

;******************************************
bworddechigh              equ    3ah   ;***
bworddeclow               equ    3bh   ;***
worddechigh               equ    3ch   ;***
worddeclow                equ    3dh   ;***

bwordinchigh              equ    3ah   ;***
bwordinclow               equ    3bh   ;***
wordinchigh               equ    3ch   ;***
wordinclow                equ    3dh   ;***
;******************************************



;
; const define
sp_reg                    equ    60h


lightchannelconsthigh     equ    0    ;defult 5 channel
lightchannelconstlow      equ    6

defultlocalrecodehigh     equ    0
defultlocalrecodelow      equ    50   ;defult light address is 50

savedmxstartaddhigh       equ    00  ;defult dmx input save ram address
savedmxstartaddlow        equ    01







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

;p1
erambusyr      bit    p1.0
eromintr       bit    p1.1
;all null

;p2
ramadd8        bit    p2.0
ramadd9        bit    p2.1

;p3
dmxrxd         bit    p3.0
dmxtxd         bit    p3.1

statusled      bit    p3.5
ramwrite       bit    p3.6
ramread        bit    p3.7

;************************************
;          const define

;*********************************
;*********the progamer is start***
;*********************************
          org    0000h
          ljmp   initiall_programer
          org    0023h
          ljmp   interrupt_uartinput
          org    0030h
initiall_programer:
          mov    ip,#10h   ;the  uart ip
          mov    ie,#10h   ; enable uart interrput
          mov    sp,#sp_reg
          mov    tmod,#21h

          mov    pcon,#00h

          mov    p1,#0ffh
          mov    p2,#00h
          mov    p3,#0ffh

          mov    status2,#00h    ;clr  status

;initiall uart code
          mov       scon,#0dch
          setb      et1
          setb      pt1
          mov       th1,#0ffh
          mov       tl1,#0fdh
          setb      tr1



;         colner light address
          mov       locallightrecodehigh,#defultlocalrecodehigh
          mov       locallightrecodelow,#defultlocalrecodelow
          mov       bworddechigh,locallightrecodehigh
          mov       bworddeclow,locallightrecodelow

          mov       worddechigh,#00
          mov       worddeclow,#01

          lcall     word_dec
          jb        allzorebf,main_localrecodeload
          mov       locallightrecodehigh,bworddechigh
          mov       locallightrecodelow,bworddeclow
          ljmp      main_initiall_end
main_localrecodeload:
          mov       locallightrecodehigh,#00
          mov       locallightrecodelow,#01
          ljmp      main_initiall_end

main_initiall_end:
          mov      ie,#90h   ; enable uart interrput
          ljmp      main_programer





;************************************
;****** the programer loop test *****
;************************************
main_programer: ;1ms
;*************************************

           ljmp    $

;*****************************************
;*****************************************
;  space 1ms   frame to frame 200us
;*****************************************
;*****************************************
interrupt_uartinput:
           push     acc
           push     psw
           jbc      ri,interrupt_uartinput_start
interrupt_uartinput_txd:
           clr      ti
           setb     txd
           ljmp     interrupt_uartinput_quit
interrupt_uartinput_start:
           clr      ri
           mov      a,sbuf
           mov      dmxinputbuff,a
interrupt_uartinput_startbftest:  ;the rb8=0 is subf=0
           jb       rb8,interrupt_uartinput_fristtest
                      ;  mov      c,rb8
                      ;  jc       interrupt_uartinput_fristtest
           ; the dmx frame speca byte
           mov      a,dmxinputbuff
           jnz      interrupt_uartinput_loadstatus ;     data rxd error
           ; frame speca byte true set bf bit
           setb     fristaddallzorebf
           setb     dmxoverend
           clr      lightadddobf

           ; load the light recode address
           mov      dmxchannelcounthigh,locallightrecodehigh
           mov      dmxchannelcountlow,locallightrecodelow

           mov      lightchannelhigh,#lightchannelconsthigh
           mov      lightchannellow,#lightchannelconstlow


           ljmp     interrupt_uartinput_quit

interrupt_uartinput_fristtest: ;rb8=1 is subf=0
           jnb      fristaddallzorebf,interrupt_uartinput_rxddata
           jnb      dmxoverend,interrupt_uartinput_loadstatus
           mov      a,dmxinputbuff
           jnz      interrupt_uartinput_loadstatus;      data rxd error
           clr      fristaddallzorebf
           ljmp     interrupt_uartinput_quit
interrupt_uartinput_rxddata:
           jnb      dmxoverend,interrupt_uartinput_loadstatus
           jb       lightadddobf,interrupt_uartinput_datastore
           ;; the local count end test
           mov      bworddechigh,dmxchannelcounthigh
           mov      bworddeclow,dmxchannelcountlow
           mov      worddechigh,#00
           mov      worddeclow,#01
           lcall    word_dec
           mov      a,dmxinputbuff
           cjne     a,#0ffh,lamp
           mov      p3,#0ffh
           mov      dmxchannelcounthigh,bworddechigh
           mov      dmxchannelcountlow,bworddeclow
           jb       allzorebf,interrupt_uartinput_rxddataint
           ljmp     interrupt_uartinput_quit
lamp:      mov      p3,#00h;
interrupt_uartinput_rxddataint:

           ; set rxd data store position
           mov      dmxdatastorehigh,#savedmxstartaddhigh
           mov      dmxdatastorelow,#savedmxstartaddlow


           setb      lightadddobf


           ljmp     interrupt_uartinput_quit


;*******************************************
interrupt_uartinput_loadstatus:
          clr       fristaddallzorebf
          clr       lightadddobf
          clr       dmxoverend
          ljmp      interrupt_uartinput_quit
interrupt_uartinput_quit:
           pop      psw
           pop      acc
           reti
;*******************************************




interrupt_uartinput_datastore:
           mov      dph,dmxdatastorehigh
           mov      dpl,dmxdatastorelow

           mov      a,dmxinputbuff

           movx     @dptr,a

           mov      bworddechigh,lightchannelhigh
           mov      bworddeclow,lightchannellow
           mov      worddechigh,#00
           mov      worddeclow,#01
           lcall    word_dec
           mov      lightchannelhigh,bworddechigh
           mov      lightchannellow,bworddeclow
           jnb      allzorebf,interrupt_uartinput_addressinc






           cpl      statusled

           ljmp     interrupt_uartinput_loadstatus
interrupt_uartinput_addressinc:
           ;the ram address inc
           mov      bworddechigh,dmxdatastorehigh
           mov      bworddeclow,dmxdatastorelow
           mov      worddechigh,#00
           mov      worddeclow,#01
           lcall    word_inc
           mov      dmxdatastorehigh,bworddechigh
           mov      dmxdatastorelow,bworddeclow



           ljmp     interrupt_uartinput_quit

;*****************************************
;*****************************************
word_dec:
           mov      a,bworddechigh
           cjne     a,worddechigh,word_dec_hightest
           ljmp     word_dec_lowcomp
word_dec_hightest:
           jc       word_dec_allzore
           ljmp     word_dec_start
word_dec_lowcomp:
           mov      a,bworddeclow
           cjne     a,worddeclow,word_dec_lowtest
           ljmp     word_dec_start
word_dec_lowtest:
           jc       word_dec_allzore
           ljmp     word_dec_start
word_dec_start:
           mov      a,bworddeclow
           clr      c
           subb     a,worddeclow
           mov      bworddeclow,a

           mov      a,bworddechigh
           subb     a,worddechigh
           mov      bworddechigh,a
word_dec_zoretest:
           mov      a,bworddechigh
           orl       a,bworddeclow
           jz       word_dec_allzore
           ljmp     word_dec_notzore
word_dec_allzore:
           setb     allzorebf
           ljmp     word_dec_quit
word_dec_notzore:
           clr      allzorebf
           ljmp     word_dec_quit
word_dec_quit:
           ret
;word dec end
;****************************************
word_inc:
           mov       a,bwordinclow
           add       a,wordinclow
           mov       bwordinclow,a

           mov       a,bwordinchigh
           addc      a,wordinchigh
           mov       bwordinchigh,a
word_inc_end:
           ret
;****************************************
;*****************************************
;*****************************************
;*****************************************
;*****************************************
          end

⌨️ 快捷键说明

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