24
CHAPTER 3 Overview of the Standard I/O Library
mov i:RS_CTRL, #0
call delay
mov i:RS_CTRL, #RCLR
call delay
mov i:RS_CTRL1, #RMODE1; mode (MB89731 original)
call delay
mov i:RS_BOUD, #RBOUD; baud rate
call delay
mov i:RS_CTRL, #RMODE; mode (8251 compatible)
call delay
mov i:RS_CTRL, #RCOMM; commond
call delay
retp
EVEN
delay: mv a,#UsartAccessDelayTime
delay01: decw a
bnz delay01
ret
ALIGN 2
;-----------------------------------------------------------------------
; chrout (output 8bit data )
;
; *PARAMETER*
; R0 output data
; *RETURN*
; None
; *ERROR CODE*
; None
;-----------------------------------------------------------------------
.export chrout
chrout:
bbc i:RS_CTRL:TXRDY,chrout; Wait transmit ready
mov a,r0
mov i:RS_DATA,a ; Write data
retp
ALIGN 2
;-----------------------------------------------------------------------
; chrinp (input 8bit data )
;
; *PARAMETER*
; None
; *RETURN*
; AL h'0000 - h'00FF : input data
; h'FFFF : no data
; *ERROR CODE*
; None
;-----------------------------------------------------------------------
.export chrinp
chrinp:
bbc i:RS_CTRL:RXRDY,chrinp_nod; Wait receive ready
mov a,i:RS_DATA ; Read data
retp
chrinp_nod: movw a,#h'ffff
retp
ALIGN 2
.end
Note: The above example is for a suppert board for the F²MC-16LX. When using different
target board, create a program to match the requirements of the I/O resource being
used.
Figure 3.3 Example of Creating a Standard I/O Driver (Continued)