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

📄 485.asm

📁 自制的云台控制器的接收部分
💻 ASM
字号:
           org     0000h
           mov     SCON,#50h
           mov     TMOD,#20h

           mov     TH1,#0f3h
           mov     TL1,#0f3h       ;初始化串口,速率2400
           setb    TR1             ;启动定时器
           clr     p1.0            ;设置485为接收状态

           setb    p1.3
           setb    p1.4
           setb    p1.6
           setb    p1.7            ;初始化四个控制口
           clr     RI
           clr     c
           call    long_delay
a1:        jb      RI,uart
           jmp     a1
    uart:
           mov     a,SBUF
           call    long_delay

           mov     40h,a

           mov     30h,40h
           mov     a,30h
           swap    a
           anl     a,#0fh
           jz      lianxu
           ljmp    diandong

lianxu:    mov     a,30h
           cjne    a,#00h,tel2

           setb    p1.6
           setb    p1.3
           setb    p1.4
           setb    p1.7
           call    delay

           clr     p1.7              ;执行连续右
           jmp     out_tel

tel2:      mov     a,30h
           cjne    a,#01h,tel3

           setb    p1.7
           setb    p1.3
           setb    p1.4
           setb    p1.6
           call    delay

           clr     p1.6              ;执行连续左
           jmp     out_tel

tel3:      mov     a,30h
           cjne    a,#02h,tel4

           setb    p1.7
           setb    p1.6
           setb    p1.4
           setb    p1.3
           call    delay

           clr     p1.3               ;执行连续上
           jmp     out_tel

tel4:      mov     a,30h
           cjne    a,#03h,tel_stop

           setb    p1.7
           setb    p1.6
           setb    p1.3
           setb    p1.4
           call    delay

           clr     p1.4                ;执行连续下

           jmp     out_tel

tel_stop:  mov     a,30h
           cjne    a,#04h,out_tel

           setb    p1.7
           setb    p1.6
           setb    p1.3
           setb    p1.4               ;停止连续工作


out_tel:   clr     c
           clr     RI
           jmp     a1


diandong:  mov     a,30h
           anl     a,#0fh
           cjne    a,#00h,dian_tel2
           setb    p1.7
           setb    p1.6
           setb    p1.3
           setb    p1.4
           call    delay

           clr     p1.7                  ;向右转动一次
           call    delay
           call    delay
           setb    p1.7
           jmp     dian_out_tel

dian_tel2: mov     a,30h
           anl     a,#0fh
           cjne    a,#01h,dian_tel3
           setb    p1.7
           setb    p1.3
           setb    p1.4
           setb    p1.6
           call    delay

           clr     p1.6                  ;向转动一次
           call    delay
           call    delay
           setb    p1.6
           jmp     dian_out_tel

dian_tel3: mov     a,30h
           anl     a,#0fh
           cjne    a,#02h,dian_tel4
           setb    p1.7
           setb    p1.6
           setb    p1.4
           setb    p1.3
           call    delay

           clr     p1.3                  ;向上转动一次
           call    delay
           call    delay
           setb    p1.3
           jmp     dian_out_tel

dian_tel4: mov     a,30h
           anl     a,#0fh
           cjne    a,#03h,dian_out_tel
           setb    p1.7
           setb    p1.6
           setb    p1.3
           setb    p1.4
           call    delay
           
           clr     p1.4                   ;向下转动一次
           call    delay
           call    delay
           setb    p1.4
           jmp     dian_out_tel
           
dian_out_tel:
           clr     RI
           clr     c
           jmp     a1

delay:     mov     r2,#04
  dl2:     mov     r0,#255
  dl1:     mov     r1,#255
           djnz    r1,$
           djnz    r0,dl1
           djnz    r2,dl2
           ret

long_delay:mov    r2,#08
  d2:      mov     r0,#255
  d1:      mov     r1,#255
           djnz    r1,$
           djnz    r0,d1
           djnz    r2,d2
           ret


           end

⌨️ 快捷键说明

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