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

📄 infrad.asm

📁 采用红外传感器实现机器人的避障算法,并且用VC++实现演示的操作!里面有一些红外传感器的一些资料!
💻 ASM
字号:
      infcord  data  23h             ;the data which wait to send at the address
      lowbit   bit   00h             ; Is it the low voltage station
   Iscodebit   bit   01h             ; Is it the code
;-----------------------------------------------
                org  0000h
                ajmp   Main
;------------------interupt----------------------
                org   0003h
                clr   ex0
                org   000bh
                jmp   Emit
                org   0013h
                clr   ex1
                org   001bh
                clr   et1
                org   0023h
                clr   es
;-----------------T0 interupt-----------------

     Emit:      jb    lowbit,  iscode     ; if lowbit==0 then is code else low voltage
                cpl   p1.0                ;generat pluse 方波  38k
    iscode:     djnz  r7,  Quit
                clr   tr0
Quit:           reti
;-------------------Main----------------------
     Main:      mov   sp ,  #60h
                acall    Sysini            ;system initialize
     Mainloop:  mov   c,  tr0
                jc   Mainloop              ;if Tr0==1 then emit continue else emit next bit
                clr  p1.0                  ;do not emit
                mov  c,     lowbit         ;get the stuation of lowbit
                cpl  lowbit                ;send the 相反的 bit
                jnb   lowbit, movr7        ;lowbit==0 is low voltage
                mov   a,  infcord          ;get the code
                rlc   a                    ;get one bit
                mov   infcord, a           ;save new data
                djnz  r6,    Gonext
                mov  infcord , #10100101b
                mov   r6,      #8
       Gonext:  jnc   Iszero
                mov   r7,  #130
                jmp   Quit1
       Iszero:  mov   r7,  #43
                jmp   Quit1
        Movr7:  mov   r7, #42
        Quit1:  setb  tr0
                ajmp   Mainloop


;---------------------------------------------
    Sysini:     mov    tmod, #00000010b     ;8 bit auto lode
                mov    ie,  #10000010b      ;enable T0
                mov    infcord,  #10100101b ; code
                mov    r6,       #8         ;turn left 8 times
                mov    r7,  #43             ;low voltage time
                mov    th0,  #243           ; repeat data
                mov    tl0,  #243           ; initialize value
                setb   tr0                  ; start T0
                ret
;---------------------------------------------




⌨️ 快捷键说明

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