單片機(jī)和 FIFO 的接口匯編程序
;***********************************
ef bit p3.3 ;fifo empty flag
rst bit p3.5 ;reset fifo
read bit p3.7 ;read fifo
org 0000h
ljmp main
org 0030h
main:
;------ initial timer
mov tmod,#00100001b ;timer0 mode 1 (16 bit)
;timer1 mode 2 (8 bit auto reload)
mov a,pcon ;
orl a,#10000000b ;
mov pcon,a ;setb SMOD bit
mov th1,#0fdh ;19200ps @ 11.0592Mhz OSC
setb tr1 ;turn on timer1
;------ initial serial communication port
mov scon,#01010000b ;mode 1 (8 bit UART,variable Baud)
clr ti
setb read
clr rst
nop
setb rst ;reset fifo
start:
jnb ef,$ ;if no data then wait
clr read
nop
mov a,p1
nop
setb read ;read data from fifo
jnb ti,$ ;send data
clr ti
mov sbuf,a
ajmp start
end
評論