User`s manual

BL4S100 Users Manual 43
4.2.2 Serial Communication
The following sample programs are found in the SAMPLES\BL4S1xx\RS232 subdirectory.
PARITY.C—This sample program repeatedly sends byte values 0–127 from Serial Port D
to Serial Port F. The program will cycle through parity types on Serial Port D. Serial
Port F will always be checking parity, so parity errors should occur during most
sequences. The results are displayed in the Dynamic C STDIO window.
Connect Tx/1-W to CTS (RxF) on header J5 before compiling and
running this sample program. You may wish to do <Ctrl-Q> to stop
the program to see the data, which go by rather quickly.
NOTE: For the sequence that does yield parity errors, the errors won't
occur for each byte received. This is because certain byte patterns along with the stop bit will
appear to generate the correct parity for the UART.
SIMPLE3WIRE.C—This program demonstrates basic RS-232
serial communication using the Dynamic C STDIO window. Fol-
low these instructions before running this sample program.
Connect Tx/1-W to CTS (RxF), then connect Rx to RTS (TxF)
before compiling and running this sample program.
SIMPLE5WIRE.C—This program demonstrates 5-wire RS-232 serial communication
using the Dynamic C STDIO window. Follow these instructions before running this
sample program.
Before you compile and run this sample program, connect Tx/1-W
to Rx, then connect RTS to CTS.
To test flow control, disconnect RTS from CTS while running this
program. Characters should stop printing in the Dynamic C STDIO
window and should resume when RTS and CTS are connected again.
COMPUTER_PARITY.C—This sample program demonstrates using parity over a simple
three-wire RS-232 connection. Parity is selected for the BL4S100 and for the serial ter-
minal emulation program. Characters typed in either the Dynamic C STDIO window or
in the serial terminal emulation program are echoed in both displays. Parity errors are
counted and displayed by the Rabbit microprocessor on the BL4S100.
Before you compile and run this sample program, use the
long serial cable (Part No. 540-0094) to connect Tx (brown
wire), Rx (red wire) and GND (black wire) on header J5 to
a PC COM port.
Open a Hyperterminal session (
Start > Accessories >
Communications
). Select the PC COM port the cable is
connected to and set the default serial parameters:
Bits per second: 115200
Data bits: 8
Parity: None
J5
RX TX/1W CTS RTS +5 V GND
J5
RX TX/1W CTS RTS +5 V GND
J5
RX TX/1W CTS RTS +5 V GND
J5
RX TX/1W CTS RTS +5 V GND
Rx
Tx
GND