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

📄 chap6.asm

📁 Motorola 6812芯片开发的接口程序。
💻 ASM
字号:
; Chapter 6 6812 assembly language programs; Jonathan W. Valvano; This software accompanies the book,; Real Time Embedded Systems published by Brooks Cole;; Program 6.1. Initialization of a periodic interrupt using input capture and an external clock.; MC68HC812A4;external signal to PT3/IC3TIME rmb  2      ;every 1 msInit sei         ;make atomic     bclr TIOS,$08 ;PT3=input capture     clr  DDRT     ;PT3 is input     movb #$80,TSCR ;enable TCNT     movb #$32,TMSK2 ; 500 ns clk     ldaa TCTL4  ;old value     anda #$7F   ;Clear EDG3B=0     oraa #$40   ;EDG3BA =01      staa TCTL4  ;on rise of IC3     bset TMSK1,$08  ;Arm IC3F      movw #0,TIME    ;init global     movb #$08,TFLG1 ;clear IC3F      cli         ;enable     rts; Program 6.2. Periodic interrupt using input capture and an external clock.; MC68HC812A4IC3Han brset #$08,TFLG1,ClkHan   [4]        swiClkHan movb #$08,TFLG1 ;clr IC3F [4]       ldx  TIME                 [3]                                        inx                       [1]                                        stx  TIME                 [3]                                        rti       org  $FFE8  ;timer channel 3       fdb  IC3Han;  Program 6.4. Initialization for period measurement.; MC68HC812A4;external signal to PT1/IC1Period rmb  2   ;units 500 nsFirst  rmb  2   ;TCNT at first edgeDone   rmb  1   ;set each risingInit sei            ;make atomic     bclr TIOS,$02  ;PT1=input capture     bclr DDRT,$02  ;PT1 is input     movb #$80,TSCR ;enable TCNT     movb #$32,TMSK2 ;500ns clk     ldaa TCTL4  ;old value     anda #$F3   ;Clear EDG1B=0     oraa #$04   ;EDG1BA =01      staa TCTL4  ;on rise of IC1     movw TCNT,First ;init global     clr  Done     movb #$02,TFLG1 ;clear IC1F     bset TMSK1,$02  ;Arm IC1F      cli             ;enable     rts;  Program 6.5. ISR for period measurement.; MC68HC812A4IC1Han movb #$08,TFLG1 ;clear C3F [4]       ldd  TC1                   [3]                                        subd First                 [3]                                        std  Period                [3]       movw TC1,First             [6]       movb #$FF,Done             [4]                                        rti                        [8]       org  $FFEC  ;timer channel 1       fdb  IC1Han;  Program 6.11. Ritual written in assembly language for the pulse width measurement.; MC68HC812A4; B=PB7,  Q=PT2/IC2Init   bclr TIOS,$04  ;PT2=input capt.       movb #$90,TSCR ;enable, fast clr       movb #$32,TMSK2 ;500 ns clk       clr  TMSK1      ;gadfly, C2I=0       bclr DDRB,$80       rts;  Program 6.12. Assembly language pulse width measurement.; MC68HC812A4; return Reg D as R in Kohm Meas   movb #$10,TCTL4 ;Rising edge       movb #$04,TFLG1 ;C2F=0       bclr PORTB,$80  ;PB7=0       bset PORTB,$80  ;PB7=0         First  brclr TFLG1,$04,First;Wait for first rising edge       ldy  TC2  ;TCNT at rising, C2F=0       movb #$20,TCTL4 ;Falling edge       pshy       ;Save on stackSecond brclr TFLG1,$04,Second;Wait for next falling edge       ldd  TC2 ;TCNT at falling         subd 2,SP+  ;RegD=pulse width 1000 to 2000 cyc       subd #1000  ;0<=R<=1000Kohm       rts;  Program 6.19. Assembly language ritual for periodic interrupt using output compare.; MC68HC812A4TIME   rmb  2     ;inc every 1msInit   sei        ;make atomic       bset TIOS,$20   ;OC5       movb #$80,TSCR  ;enable        movb #$32,TMSK2 ;500 ns clk       bset TMSK1,$20  ;Arm OC5       movw #0,TIME    ;initialize       movb #$20,TFLG1 ;clear C5F       ldd  TCNT  ;current time       addd #2000 ;first in 1 ms       std  TC5        cli        ;enable       rts;  Program 6.20. Assembly language ISR for periodic interrupt using output compare.; MC68HC812A4OC5HAN ldx  TIME               [3]       inx                     [1]       stx  TIME               [2]       movb #$20,TFLG1 ;Acknowledge        ldd  TC5                       addd #2000 ;next              std  TC5                      rti       org  $FFE4       fdb  OC5HAN;  Program 6.22. Ritual for the assembly language implementation of the squarewave using output compare.; MC68HC812A4Period rmb  2    ;units 祍ecInit   sei        ;make atomic       bset TIOS,$08   ;OC3       bset DDRT,$08   ;PT3 output       movb #$80,TSCR  ;enable       movb #$32,TMSK2 ;500 ns clk       bset TMSK1,$08  ;Arm OC3       bset TCTL2,$40  ;OL3=1       bclr TCTL2,$80  ;OM3=0       movb #$08,TFLG1 ;clear C3F       ldd  TCNT  ;current time       addd #50   ;first in 25祍       std  TC3        cli        ;enable       rts;  Program 6.23. Assembly language squarewave using output compare.; MC68HC812A4OC3HAN movb #$08,TFLG1 ;Ack       [4]       ldd  TC3                   [3]       addd Period ;next          [3]       std  TC3                   [2]       rti                        [8]       org  $FFE8       fdb  OC3HAN;  Program 6.25. Assembly language initialization pulse-width modulated squarewave using output compare.; MC68HC812A4High rmb  2  ;number of cycles highLow  rmb  2  ;number of cycles lowRITUAL sei        ;make atomic       bset TIOS,$08   ;OC3       bset DDRT,$08   ;PT3 output       movb #$80,TSCR  ;enable       movb #$32,TMSK2 ;500 ns clk       bset TMSK1,$08  ;Arm OC3       bset TCTL2,$C0  ;OL3=1,OM3=1       movb #$08,TFLG1 ;clear C3F       ldd  TCNT  ;current time       addd #50   ;first in 25祍       std  TC3        cli        ;enable       rts;  Program 6.26. Assembly language ISR for pulse-width modulated squarewave using output compare.; MC68HC812A4OC3HAN movb #$08,TFLG1 ;Ack       [4]       ldaa TCTL2  ;rise/fall?    [3]       bita #$40                  [1]       beq  zero                [1/3]one    ldd  TC3                   [3]       addd High ;now PT3 is 1    [3]       std  TC3                   [2]       bclr TCTL2,$40             [4]       bra  done                  [3]zero   ldd  TC3                   [3]       addd Low  ;now PT3 is 0    [3]       std  TC3                   [2]       bset TCTL2,$40             [4]done   rti                        [8]       org  $FFE8       fdb  OC3HAN

⌨️ 快捷键说明

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