?? chap7.asm
字號:
; Chapter 7 6811 assembly language programs
; Jonathan W. Valvano
; This software accompanies the book,
; Real Time Embedded Systems published by Brooks Cole
;
; Program 7.1. Assembly subroutine to output a character using the SCI port.
; MC68HC11A8
OutChar ldab SCSR ;status
bitb #$80 ;tdre?
beq OutChar
staa SCDR ;output
rts
; Program 7.2. A second assembly subroutine to output a character using the SCI port.
; MC68HC11A8
OutChar staa SCDR ;output
wait2 ldab SCSR ;status
bitb #$80 ;tdre?
beq wait2
rts
; Program 7.3. A third assembly subroutine to output a character using the SCI port.
; MC68HC11A8
OutChar staa SCDR ;output
wait3 ldab SCSR ;status
bitb #$40 ;TC?
beq wait3
rts
; Program 7.5. Assembly ritual to initialize the SCI port to accept receiver interrupts.
; MC68HC11A8
RITSCI sei ;make atomic
ldaa #$31 ;4800 baud
staa BAUD
ldaa #00 ;M=0, 8 bit data
staa SCCR1 ;1 stop
ldaa #$2C
staa SCCR2
bsr CLRQ ;Initialize FIFO
cli ;Enable
rts
; Program 7.6. Simple polling for receiver interrupts.
; MC68HC11A8
SCIHAN ldaa SCSR
anda #$20 RDRF set?
bne INSCI
; Program 7.7. Polling for ones and zeros for receiver interrupts.
; MC68HC11A8
SCIHAN ldaa SCSR XX1XXXX0
anda #$21 RDRF set?
cmpa #$20 Bit0=0?
beq INSCI
; Program 7.8. Assembly ISR for receiver interrupts.
; MC68HC11A8
INSCI ldaa SCSR ;status
anda #$0E ;OR, NF, FE
bne ERROR
ldaa SCDR ;data, ack
bsr PutFifo ;Communicate
bcs ERROR ;FIFO full?
rti
; Program 7.10. Assembly ritual to initialize the SCI port to accept receiver and transmitter interrupts.
; MC68HC11A8
Init ldaa #$30 ;9600 baud
staa BAUD
ldaa #$00 ;mode
staa SCCR1
jsr RxInitFifo ;empty
jsr TxInitFifo ;empty
ldaa #$2c ;just RDRF
staa SCCR2 ;enable SCI
cli
rts
Program 7.11. Assembly subroutines called by the main program to perform serial I/O.
; MC68HC11A8
InChar jsr RxGetFifo
beq InChar
rts
OutChar jsr TxPutFifo ;save
beq OutChar ;full?
ldab #$AC ;arm both
stab SCCR2 ;TDRE, RDRF
rts
; Program 7.12. Assembly ISR for receiver and transmitter interrupts.
; MC68HC11A8
SCIhdlr ldaa SCSR anda #$20 ;check RDRF beq ChkTDRE ;Not RDRFInSCI ldaa SCDR ;ASCII code bsr RxPutFifoChkTDRE ldaa SCSR
anda #$80 ;check TDRE
beq SCIdone ;Not TDRE
OutSCI bsr TxGetFifo
beq nomore
staa SCDR ;start next
bra SCIdone
nomore ldaa #$2C
staa SCCR2 ;disarm TDRE
SCIdone rti
; Program 7.13. Assembly functions for serial output using DTR synchronization.
; MC68HC11A8
;PA0/IC3 is DTR
OutChar ldab PORTA ;wait for
bitb #$01 ; DTR=0
bne OutChar ;
ldab SCSR ;status
bitb #$80 ;tdre?
beq OutChar
staa SCDR ;output
rts
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -