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

📄 chap3.asm

📁 摩托罗拉Mc6811利程
💻 ASM
字号:
; Chapter 3 6811 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.; MC68HC11A8; PortB is DATA, STRB=GOInit   clr  PIOC       rtsOut    staa PORTB       ldd  #2857OLoop  subd #1     ;[4]       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.; MC68HC11A8; PortC is DATA, STRB=GOInit  ldaa #$01  ;INVB=1      staa PIOC      clr  DDRC      rtsIn    staa PORTB ;GO pulse       mul        ;[10]      ldaa PORTC      rts; Program 3.10. Assembly language routines to initialize and read from a keyboard.; MC68HC11A8; PortC=DATA, STRA=STROBEInit ldaa #$02  ;EGA=1     staa PIOC     ldaa #$80  ;PC7=output     staa DDRC     ldaa PIOC  ;STAF=0     ldaa PORTCL     clr  PORTC ;PC7=0     rtsIn   ldaa PIOC ; wait for STAF     bpl  In     ldaa PORTCL     rts; Program 3.12. Assembly language routines to initialize and read from an A/D.; MC68HC11A8; PortC=DATA STRA=DONE STRB=GOInit  ldaa #$03  ;EGA=1, INVB=1      staa PIOC      ldaa #$00  ;PC=input      staa DDRC      ldaa PIOC  ;STAF=0      ldaa PORTCL      rtsIn    staa PORTB ;GO pulseloop  ldaa PIOC  ;wait for STAF      bita #$80      beq  loop      ldaa PORTCL      rts; Program 3.14. Handshaking assembly language routines to initialize and read from a sensor.; MC68HC11A8; PortC=DATA STRA=READY STRB=ACKInit  ldaa #$13  ;Input hndshake      staa PIOC      ldaa #$00  ;PC=input      staa DDRC      ldaa PIOC  ;STAF=0      ldaa PORTCL      rtsIn    ldaa PIOC  ;wait for STAF      bita #$80      beq  loop      ldaa PORTCL ;read DATA      rts; Program 3.15. Example comment detailing what and why a value is used to initialize a control register.; PortC ritual, Set PC7-PC0 inputs = sensor DATA; PIOC ($1002); 7 STAF    Read Only Set on rise of STRA; 6 STAI 0  Gadfly, no interrupts; 5 CWOM 0  Normal outputs; 4 HNDS 1  Input handshake; 3 OIN  0; 2 PLS  0  ACK=STRB goes to 0 on rise of READY; 1 EGA  1  STAF set on rise of READY=STRA; 0 INVB 1  ACK=STRB goes to 1 on a ReadCL ; STRB=ACK signifies 6811 status 0 means busy,1 means done; STRA=READY rising edge when new sensor data is ready; Program 3.17. Handshaking assembly language routines to initialize and write to a printer.; MC68HC11A8; PC=DATA STRA=READY STRB=START; 7 STAF    Set on rise of STRA; 6 STAI 0  Gadfly, no interrpt; 5 CWOM 0  Normal outputs; 4 HNDS 1  Output handshake; 3 OIN  1; 2 PLS  1  Pulse on Write CL; 1 EGA  1  STAF set on ( READY; 0 INVB 0  Negative logic pulse Init  ldaa #$1E  ;Output hndshke      staa PIOC      ldaa #$FF  ;PC=output      staa DDRC      rtsOut   staa PORTCL ;out, pulsewait  ldab PIOC   ;wait for STAF      bitb #$80      beq  wait      rts; Program 3.19. Assembly language initialization of the DS1620; MC68HC11A8; PD5=RST PD4=CLK PD3=DQInit ldaa #$38  ;PD5-3 output     staa DDRD     ldaa #$18  ;RST=0,CLK=1       staa PORTD ;DQ=1     rts; Program 3.21. Assembly language helper functions for the DS1620; MC68HC11A8;output 8 bits, Reg A=dataout8  ldab #8       ;8 bitsclop  bclr 0,x,#$10 ;CLK=0      lsra          ;lsb first      bcc  set0      bset 0,x,#$08 ;DQ=1      bra  nextset0  bclr 0,x,#$08 ;DQ=0next  bset 0,x,#$10 ;CLK=1      decb      bne  clop      rtsstart ldx  #PORTD      bset 0,x,#$20 ;RST=1      ldaa #$EE      bsr  out8      bclr 0,x,#$20 ;RST=0      rtsstop  ldx  #PORTD      bset 0,x,#$20 ;RST=1      ldaa #$22      bsr  out8      bclr 0,x,#$20 ;RST=0      rts; Program 3.23. Assembly language functions to set the configuration register on the DS1620; MC68HC11A8config ldx  #PORTD       psha       bset 0,x,#$20 ;RST=1       ldaa #$0C       bsr  out8       pula        bsr  out8       bclr 0,x,#$20 ;RST=0       rts; Program 3.25. Assembly language 9-bit output helper function for the DS1620; MC68HC11A8;output 9 bits, Reg D=dataout9   ldx  #9       ;9 bitsolop   bclr 0,x,#$10 ;CLK=0       lsrd          ;lsb first       bcc  oset0       bset 0,x,#$08 ;DQ=1       bra  onextoset0  bclr 0,x,#$08 ;DQ=0onext  bset 0,x,#$10 ;CLK=1       dex       bne  olop       rts; Program 3.26. Assembly language functions to set the threshold registers on the DS1620; MC68HC11A8;Reg D is temperature valueWriteTH psha        pshb        ldx  #PORTD        bset 0,x,#$20 ;RST=1        ldaa #$01        bsr  out8        pulb        pula        bsr  out9        bclr 0,x,#$20 ;RST=0        rts;Reg D is temperature valueWriteTL psha        pshb        ldx  #PORTD        bset 0,x,#$20 ;RST=1        ldaa #$02        bsr  out8        pulb        pula        bsr  out9        bclr 0,x,#$20 ;RST=0        rts; Program 3.28. Assembly language functions to read the configuration register on the DS1620; MC68HC11A8;input 8 bits, Reg A=datain8    ldy  #8       ;8 bits       ldaa DDRD       anda #$F7     ;DQ input       staa DDRDilop   bclr 0,x,#$10 ;CLK=0       lsra          ;lsb first       brclr 0,x,#$08,inext       oraa #$80 ;DQ=1inext  bset 0,x,#$10 ;CLK=1       dey       bne  ilop       ldab DDRD       orab #$08     ;DQ output       stab DDRD       rts;Reg A is config valueReadConfig ldx  #PORTD        bset 0,x,#$20 ;RST=1        ldaa #$AC        bsr  out8        bsr  in8        bclr 0,x,#$20 ;RST=0        rts; Program 3.29. Assembly language 9-bit read helper function for the DS1620; MC68HC11A8;input 9 bits, Reg D=datain9    ldy  #9       ;9 bits       ldaa DDRD       anda #$F7     ;DQ input       staa DDRD       clrajlop   bclr 0,x,#$10 ;CLK=0       lsrd          ;lsb first       brclr 0,x,#$08,jnext       oraa #$01 ;DQ=1jnext  bset 0,x,#$10 ;CLK=1       dey       bne  jlop       psha       ldaa DDRD       oraa #$08     ;DQ output       staa DDRD       pula       rts; Program 3.30. Assembly language functions to read the temperatures from the DS1620; MC68HC11A8;Reg D returned as TH valueReadTH ldx  #PORTD       bset 0,x,#$20 ;RST=1       ldaa #$A1       bsr  out8       bsr  in9       bclr 0,x,#$20 ;RST=0       rts;Reg D returned as TL valueReadTL ldx  #PORTD       bset 0,x,#$20 ;RST=1       ldaa #$A2       bsr  out8       bsr  in9       bclr 0,x,#$20 ;RST=0       rts;Reg D returned as TemperatureReadT  ldx  #PORTD       bset 0,x,#$20 ;RST=1       ldaa #$AA       bsr  out8       bsr  in9       bclr 0,x,#$20 ;RST=0       rts

⌨️ 快捷键说明

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