📄 testflash.asm
字号:
;TL16C550 REGISTER SET IO ADDRESS
;LCR:8003H DIVISOR LATCH (LSB)=8000H 当DLAB=1时
; DIVISOR LATCH (MSB)=8001H 当DLAB=1时
;IER:8001H IIR:8002H(READ ONLY)
;MCR:8004H LSR:8005H FCR:8002H(write only)
;RBR:8000H(READ ONLY)当DLAB=0时
;THR:8000H(WRITE ONLY)当DLAB=0时
;8 BIT ODD PARITY 1 BIT STOP 9600BIT/S
.mmregs
.global _Sendinit
.global _Send
.global _Recv
.global _DRDY
.text
_Sendinit:
;********************************************
;init dsp register
nop
STM #0x7fff, SWWSR
STM #0x1800,ST0
stm 1000h,ar0
stm 1000h,ar1
stm 1000h,ar2
;********************************************
LL: portr 800fh,ar2 ; read io 800fh,SET UART_MR=0,UART OUT RESET
NOP
NOP
portr 8008h,ar2;read io 8008h,flash_enable=1,ram=enable
nop
nop
UART: portr 800fh,ar2 ; read io 800fh,SET UART_MR=0,UART OUT RESET
nop
nop
STM 83H,AR1 ; READY TO WRITE THE DIVISOR 8 BIT 1 STOP ODD PARITY
PORTW AR1,8003H ;WRITE 16C550 LCR A2=0,A1=1,A0=1
;READY TO WRITE THE DIVISOR 8 BIT 1 STOP ODD PARITY
;DLAB=1 ,STICK PARITY BIT DISANBLE
nop
nop
portr 8003h,ar2 ;check 8013h register
nop
nop
STM 18H,AR1
PORTW AR1,8000H ;Divisor latch (LSB)=18H
nop
nop
portr 8000h,ar2 ;check 8010h register
nop
nop
STM 00,AR1
PORTW AR1,8001H ;Divisor latch (MSB)=00H
;SET Baud Rates=9600BIT/S
nop
nop
portr 8001h,ar2 ;check 8011h register
nop
nop
STM 03H,AR1
PORTW AR1,8003H ;SET LCR DLAB=0 enable read and write
nop
nop
portr 8003h,ar2 ;check 8013h register
nop
nop
STM 00H,AR1
PORTW AR1,8002H ;SET fcr
nop
nop
portr 8002h,ar2 ;check 8012h register
nop
nop
PORTW AR1,8001H ;SET IER=00H DISABLE ALL INTERRUPT
nop
nop
portr 8001h,ar2 ;check 8011h register
nop
nop
PORTW AR1,8004H ;SET MCR=00H DTR=1,RTS=1 OUT1,2=1 diagnostic testing
;DISABLE
NOP
nop
portr 8004h,ar2 ;check 8014h register
nop
nop
ret
;**********************************************************
;star send char
;**********************************************************
_Send:
WS:
nop
BB:
stm 03h,ar3
portw ar3,8003h ;SET LCR DLAB=0 enable read and write
NOP
NOP
portr 8003h,ar2 ;check 8013h register
NOP
NOP
WRITE: PORTW AR7,8000H;begin SEND CHAR
NOP
call wait;must be call dealy subprg
nop
stm 00h,ar2 ;can break here to see 8015h register
nop
TEST: PORTR 8005H,AR2 ;READ LSR
nop
nop
BITF AR2,20H ;TEST LSR.BIT(7)=1 ,transmit register empty or not?
BC TEST, NTC
NOP
ret
;*****************************************************
;transmit end
;*****************************************************
;*****************************************************
;begin receive data
;*****************************************************
_Recv:
ff: stm 03h,ar3
portw ar3,8003h ;SET LCR DLAB=0 enable read and write
nop
nop
portr 8003h,ar2 ;check 8013h register
nop
nop
portr 8005h,ar5 ;READ LSR
nop
nop
bitf ar5,01h ;TEST LSR.BIT(1)=1? receive data?
bc ff,ntc
portr 8000h,ar6 ;write receive data to 8000h data address
NOP
NOP
ret
*******************************************************
_DRDY: nop
nop
read: nop
nop
bc read,bio
nop
nop
ret
wait:
stm 010h,ar3
loop1:stm 020h,ar4
loop2:banz loop2,*ar4-
banz loop1,*ar3-
nop
ret
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -