📄 chap10.asm
字号:
; Chapter 10 6808 assembly language programs; Jonathan W. Valvano; This software accompanies the book,; Real Time Embedded Systems published by Brooks Cole;; Program 10.1. DMA register assignments for the MC68HC708XL36. D0S equ $0034 ; DMA Channel 0 source address, 16-bitD0D equ $0036 ; DMA Channel 0 destination address, 16-bitD0C equ $0038 ; DMA Channel 0 control register, 8-bitD0BL equ $0039 ; DMA Channel 0 block length, 8-bitD0BC equ $003B ; DMA Channel 0 byte count, 8-bitDC1 equ $004C ; DMA Control 1 register, 8-bitDSC equ $004D ; DMA Status/control register, 8-bitDC2 equ $004E ; DMA Control 2 register, 8-bit; Program 10.2. Function using burst DMA to copy memory blocks on the MC68HC708XL36. * Transfer Size bytes from Source to Destinationcopy ldhx #Source ; source address sthx D0S ldhx #Destination ; destination address sthx D0D mov #Size,D0BL ; number of bytes to transfer (0 means 256) mov #$A0,D0C ; increment source, increment destination mov #$01,DC2 ; software initiated mov #$00,DSC ; disable looping mov #$C2,DC1 ; 100%, so software continues when done rts; Program 10.3. Functions using DMA to perform I/O transmission on the MC68HC708XL36. * setup for transfer Size bytes from Source to the SCI transmit data registerinit mov #$40,SCC1 ; 8 bits, no parity mov #$10,SCC3 ; DMATE(Transmit DMA) enabled mov #$03,SCBR ; 9600 baud ldhx #SCD ; destination address is SCI Transmit data reg sthx D0D mov #$87,D0C ; increment source, static destination, byte, SCI Tx mov #$00,DSC ; disable looping mov #$0C,SCC2 ; enable SCI Tx and Rx bclr 0,DSC ; acknowledge IFC0 rts* Transfer Size bytes from Source to the SCI transmit data registersend ldhx #Source ; source address sthx D0S mov #Size,D0BL ; number of bytes to transfer (0 means 256) mov #$02,DC1 ; 25%, enable channel 0, no interrupts brclr 0,DSC,* ; wait for IFC0 to be set bclr 0,DSC ; acknowledge IFC0 rts; Program 10.4. Functions using DMA to perform I/O reception on the MC68HC708XL36. * transfer Size bytes from the SPI to Destinationrecv mov #$E2,SPCR ; Receive DMA, master, SPI enabled mov #$10,SPSCR ; divide by 2 baud rate ldhx #SPDR ; source address is SPI data reg sthx D0S ldhx #Destination ; destination address sthx D0D mov #Size,D0BL ; number of bytes to transfer (0 means 256) mov #$24,D0C ; static source, increment destination, byte, SPI Rcv mov #$00,DSC ; disable looping mov #$02,DC1 ; 25%, enable channel 0, no interrupts brclr 0,DSC,* ; wait for IFC0 to be set bclr 0,DSC ; acknowledge IFC0 rts; Program 10.5. Function using DMA to perform periodic output on the MC68HC708XL36. * transfer Size bytes from Source (waveform) to an 8-bit D/A on port Awave mov #$30,TSC ; stop and reset timer mov #$01,TDMA ; service timer 0 with DMA ldhx #181 ; timer DMA every 182 cycles sthx TMODH ; when the TCNT counts 0,1,2,...,181,0,1,2,... ldhx #91 sthx TCH0H ; DMA requested when TCNT=91 mov #$5A,TSC0 ; squarewave on PTE4 (zero at 91, toggle at overflow) ldhx #Source ; source address is the waveform table sthx D0S ldhx #PORTA ; destination address is the D/A sthx D0D mov #Size,D0BL ; number of bytes to transfer (0 means 256) mov #$80,D0C ; increment source, static destination, byte, Timer0 mov #$10,DSC ; DMA channel 0 looping mov #$02,DC1 ; 25%, enable channel 0, no interrupts mov #$00,TSC ; start timer rts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -