DMA异步写汇编程序示例.ASM
时间:10-02
整理:3721RD
点击:
- ;-----------------------------------------------------------------------------------------
- ; 异步写模块: 从模块读数据从串口发出
- ;-------------------------------------------------------------------------------------
- PWR EQU 5
- PRD EQU 6
- PWAIT EQU 7
- DMAING EQU 0
- DMADIR EQU 1
- FIFOEMPTY EQU 2
- FIFOFULL EQU 3
- DMACS EQU 4
- DMAOE EQU 5
- PKTEND EQU 6
- DMAWR EQU 6
- DMARD EQU 7
- ;-----------------------------------------------------------------------------
- ORG 0000H
- AJMP MAIN
- ORG 0040H
- MAIN: MOV TMOD, #20H ;TIMER1工作与8位自装载模式
- MOV SCON, #60H ;串口工作与模式1
- MOV PCON, #00H
- MOV TL1, #0FDH ;波特率9600
- MOV TH1, #0FDH
- CLR EA
- MOV SP, #70H
- SETB TR1
- MOV DPTR, #0CFFFH ;为不影响P2口,写地址为0CFFF,此处也可用
- ;----------------------------------------------------------
- WAITRX: CLR P3.DMACS
- JNB P2.DMAING, WAITRX
- JB P2.DMADIR, WAITRX
- JNB P2.FIFOEMPTY, WAITRX
- CLR P2.DMAOE
- NOP
- MOVX A, @DPTR ;此处也可用 MOVX A, @R0指令,此时写地址为0FF,
- NOP
- MOV SBUF, A
- ACALL DELAY1MS
- AJMP WAITRX
- ;---------------------------------------------------------
- DELAY1MS: MOV R3, 5
- DELAY1: MOV R4, 100
- DELAY0: DJNZ R4, DELAY0
- DJNZ R3, DELAY1
- RET
- ;---------------------------------------------------------
- END
支持分享