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

📄 chap3.asm

📁 Motorola 6812芯片开发的接口程序。
💻 ASM
字号:
; Chapter 3 6812 assembly language programs; Jonathan W. Valvano; This software accompanies the book,; Real Time Embedded Systems published by Brooks Cole;; Program 3.3. Assembly language routines to initialize and output to a printer.; MC68HC812A4; PortJ is DATA, PH0=GOInit   ldaa #$FF       staa DDRJ ;outputs       ldaa #$01       staa DDRH       staa PORTH ;GO=1       rtsOut    staa PORTJ ;set data       ldaa #0       staa PORTH ;GO=0       ldaa #1       staa PORTH ;GO=1       ldd  #16000OLoop  subd #1    ; [2]       bne  OLoop ; [3]       rts; Program 3.6. 6811 or 6812 assembly language routine to create an accurate time delay.; 6811 or 6812; Reg D is the number of cycles to wait;         can range from 25 to 32767Wait   addd TCNT   time at the end of delayLoop   cpd  TCNT   wait for Endt-TCNT>0       bpl  Loop       rts; Program 3.8. Assembly language routines to initialize and read from an A/D.; MC68HC812A4; PortJ is DATA, PH0=GOInit  clr  DDRJ      ldaa #$FF      staa DDRH      clr  PORTH ;GO=0      rtsIn    ldaa #1      staa PORTH ;GO=1      clr  PORTH ;GO=0      ldaa #10loop  deca       ;[1]      bne  loop  ;[3]      lda  PORTJ      rts; Program 3.10. Assembly language routines to initialize and read from a keyboard.; MC68HC812A4; PJ6-0 is DATA, PJ7=STROBEInit clr  DDRJ     ldaa #$80  ;rise on PJ7     staa KPOLJ ;key wakeup     staa KWIFJ ;clear flag     rtsIn   brclr KWIFJ,$80,In     ldaa #$80       staa KWIFJ ;clear flag     ldaa PORTJ     anda #$7F     rts; Program 3.12. Assembly language routines to initialize and read from an A/D.; MC68HC812A4; PortH=DATA PJ1=DONE PJ0=GOInit ldaa #$01  ;PJ1 input     staa DDRJ  ;PJ0 output     ldaa #$02  ;rise on PJ1     staa KPOLJ ;key wakeup     clr  DDRH  ;PA inputs     clr  PORTJ ;GO=0     rtsIn   ldaa #$02     staa KWIFJ ;clear flag     ldaa #1     staa PORTJ ;GO=1     clr  PORTJ ;GO=0;wait for rise of DONELoop brclr KWIFJ,$02,Loop     ldaa PORTH     rts; Program 3.14. Handshaking assembly language routines to initialize and read from a sensor.; MC68HC812A4; PortH=DATA PJ1=READY PJ0=ACKInit ldaa #$01  ;PJ1 input     staa DDRJ  ;PJ0 output     ldaa #$02  ;rise on PJ1     staa KPOLJ ;key wakeup     ldaa #$02     staa KWIFJ ;clear flag1     clr  DDRH  ;PH inputs     ldaa #$01     staa PORTJ ;ACK=1     rtsIn   brclr KWIFJ,$02,In     clr  PORTJ ;ACK=0     ldaa PORTH ;read DATA     ldab #$02     stab KWIFJ ;clear flag     inc  PORTJ ;ACK=1     rts; Program 3.17. Handshaking assembly language routines to initialize and write to a printer.; MC68HC812A4; PortH=DATA PJ1=READY PJ0=ACKInit ldaa #$01  ;PJ1 input     staa DDRJ  ;PJ0 output     ldaa #$02  ;rise on PJ1     staa KPOLJ ;key wakeup     ldaa #$02     staa KWIFJ ;clear flag     ldaa #$FF     staa DDRH  ;PH outputs     ldaa #$01     staa PORTJ ;START=1     rtsOut  ldab #$02     stab KWIFJ ;clear flag     clr  PORTJ ;START=0     staa PORTH ;write DATA     inc  PORTJ ;ACK=1Wait brclr KWIFJ,$02,Wait     rts; Program 3.19. Assembly language initialization of the DS1620; MC68HC812A4/MC68HC912B32; PS7=RST PS6=CLK PS5=DQInit ldaa #$E0  ;PD5-3 output     staa DDRS     ldaa #$60  ;RST=0,CLK=1       staa PORTS ;DQ=1     rts; Program 3.21. Assembly language helper functions for the DS1620; MC68HC812A4/MC68HC912B32out8  ldab #8         ;8 bitsclop  bclr PORTS,#$40 ;CLK=0      lsra            ;lsb first      bcc  set0      bset PORTS,#$20 ;DQ=1      bra  nextset0  bclr PORTS,#$20 ;DQ=0next  bset PORTS,#$40 ;CLK=1      decb      bne  clop      rtsstart bset PORTS,#$80 ;RST=1      ldaa #$EE      bsr  out8      bclr PORTS,#$80 ;RST=0      rtsstop  bset PORTS,#$80 ;RST=1      ldaa #$22      bsr  out8      bclr PORTS,#$80 ;RST=0      rts; Program 3.23. Assembly language functions to set the configuration register on the DS1620; MC68HC812A4/MC68HC912B32config psha       bset PORTS,#$80 ;RST=1       ldaa #$0C       bsr  out8       pula       bsr  out8       bclr PORTS,#$80 ;RST=0       rts; Program 3.25. Assembly language 9-bit output helper function for the DS1620; MC68HC812A4/MC68HC912B32out9    ldx  #9        ;9 bitsolop    bclr PORTS,#$40 ;CLK=0        lsrd           ;lsb         bcc  oset0        bset PORTS,#$20 ;DQ=1        bra  nextoset0   bclr PORTS,#$20 ;DQ=0onext   bset PORTS,#$40 ;CLK=1        dex        bne  olop        rts; Program 3.26. Assembly language functions to set the threshold registers on the DS1620; MC68HC812A4/MC68HC912B32;Reg D is temperature valueWriteTH pshd        bset PORTS,#$80 ;RST=1        ldaa #$01        bsr  out8        puld        bsr  out9        bclr PORTS,#$80 ;RST=0        rts;Reg D is temperature valueWriteTL pshd        bset PORTS,#$80 ;RST=1        ldaa #$02        bsr  out8        puld        bsr  out9        bclr PORTS,#$80 ;RST=0        rts; Program 3.28. Assembly language functions to read the configuration register on the DS1620; MC68HC812A4/MC68HC912B32;input 8 bits, Reg A=datain8     ldx  #8       ;8 bits        ldaa DDRD        anda #$DF     ;DQ input        staa DDRDilop    bclr PORTS,#$40 ;CLK=0        lsra           ;lsb         brclr PORTS,#$20,inext        oraa #$80       ;DQ=1inext   bset PORTS,#$40 ;CLK=1        dex        bne  ilop        ldab DDRS        orab #$20     ;DQ output        stab DDRS        rts;Reg A is config valueReadConfig        bset PORTS,#$80 ;RST=1        ldaa #$AC        bsr  out8        bsr  in8        bclr PORTS,#$80 ;RST=0        rts; Program 3.29. Assembly language 9-bit read helper function for the DS1620; MC68HC812A4/MC68HC912B32;input 9 bits, Reg D=datain9     ldx  #9       ;9 bits        ldaa DDRD        anda #$DF     ;DQ input        staa DDRD        clrajlop    bclr PORTS,#$40 ;CLK=0        lsrd           ;lsb         brclr PORTS,#$20,jnext        oraa #$01       ;DQ=1jnext   bset PORTS,#$40 ;CLK=1        dex        bne  ilop        ldab DDRS        orab #$20     ;DQ output        stab DDRS        rts; Program 3.30. Assembly language functions to read the temperatures from the DS1620; MC68HC812A4/MC68HC912B32;Reg D returned as TH valueReadTH  bset PORTS,#$80 ;RST=1        ldaa #$A1        bsr  out8        bsr  in9        bclr PORTS,#$80 ;RST=0        rts;Reg D returned as TL valueReadTL  bset PORTS,#$80 ;RST=1        ldaa #$A2        bsr  out8        bsr  in9        bclr PORTS,#$80 ;RST=0        rts;Reg D returned as temperatureReadT   bset PORTS,#$80 ;RST=1        ldaa #$AA        bsr  out8        bsr  in9        bclr PORTS,#$80 ;RST=0        rts

⌨️ 快捷键说明

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