|
用软件仿真串口
;*******************************************************************************
; Duplex UART Routines for the 8xC751 and 8xC752 Microcontrollers
;*******************************************************************************
; This is a demo program showing a way to perform simultaneous RS-232
; transmit and receive using only one hardware timer.
; The transmit and receive routines divide each bit time into 4 slices to
; allow synchronizing to incoming data that may be out of synch with outgoing
; data.
; The main program loop in this demo processes received data and sends it
; back to the transmitter in hexadecimal format. This insures that we can
; always fill up the receiver buffer (since the returned data is longer than
; the received data) for testing purposes. Example: if the letter "A" is
; received, we will echo "A41 ".
;*******************************************************************************
;$Title(Duplex UART Routines for the 751/752)
;$Date(8/20/92)
;$MOD751
;*******************************************************************************
; Definitions
;*******************************************************************************
; Miscellaneous
TxBitLen EQU -4 + 1 ; Timer slices per serial bit transmit.
RxBitLen EQU -4 + 1 ; Timer slices per serial bit receive.
RxHalfBit EQU (RxBitLen / 4) + 1 ; Timer slices for a partial bit time.
; Used to adjust the input sampling
; time point.
; Note: TxBitLen and RxBitLen are kept separate in order to facilitate the
; possibility of having different transmit and receive baud rates. The timer
; would be set up to give four slices for the fastest baud rate, and the
; BitLen for the slower channel would be set longer for the slower baud rate.
; BitLen = -4 + 1 gives four timer interrupts per bit. BitLen = -8 + 1 would
; give 8 slices, BitLen = -16 + 1 would give 16 slices, etc.
TxPin BIT P1.0 ; RS-232 transmit pin (output).
RxPin BIT P3.2 ; RS-232 receive pin (input).
RTS BIT P1.3 ; RS-232 request to send pin (output).
CTS BIT P1.6 ; RS-232 clear to send pin (input).
; Note: P1.1 and P1.2 are used to input the baud rate selection.
单片机之路 www.+mcuway+.com
[1] [2] [3] [4] [5] [6] 下一页 |
|