Syntax – Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual
Page 116
106
Serial I/O Models
• Serial input can only work successfully if the application is responsive
enough to capture the start bit of the first byte received. Usually the best
way to succeed with the serial input model is to employ bi-directional
handshaking using two additional I/O pins, so that the sender can
coordinate the transfer with the Neuron C application. If this is not
possible, the serial input can be monitored with a when(io_changes(
io-
object-name
)) statement or an I/O interrupt task, however, you must
ensure that the io_in( ) function is called less than 25% into the start bit.
For example, the start bit is approximately 4.2 ms at 2400 bps. For
reliable reception of a 2400 bps start bit, the io_in( ) function must be
called within 1 ms of the beginning of the start bit. The minimum
scheduler latency is approximately 0.24 ms with for a Series 3100 device
with a 40 MHz input clock, and is typically longer depending on the
number and type of when clauses in the application. See
on page 12 for a description of the scheduler-related I/O timing.
Scheduler latencies do not affect an I/O interrupt task; see the
Neuron C
Programmer’s Guide
for more information about timing of application-
defined interrupt tasks.
When using multiple serial I/O devices that have differing bit rates, you must use
the #pragma enable_multiple_baud compiler directive. This pragma must
appear prior to the use of any I/O function, such as, io_in( ) or io_out( ).
For serial input/output, the io_in( ) and io_out( ) functions require a pointer to the
data buffer as the input_value and output_value. The io_in( ) function returns an
unsigned short int that contains the count of the actual number of bytes received.
See the
EIA-232C Serial Interfacing with the Neuron Chip
engineering bulletin
(part no. 005-0008-01) for more information.
The serial input model provides only one bit of buffering and a maximum speed of
4800 bps. For higher bit rates, use a Smart Transceiver or Neuron Chip with
integrated UART hardware, such as the PL 3120 Smart Transceiver, PL 3150
Smart Transceiver, PL 3170 Smart Transceiver, or a Series 5000 device.
Alternatively, for bit rates up to 115.2 kbps, and 16 bytes of buffering, consider
using the PSG-20 or PSG/3 programmable serial gateway devices. See the
LTS-
20 LonTalk Serial Adapter and PSG-20 User's Guide
for more details.
Syntax
pin
input serial [baud (
const-expr
)]
io-object-name
;
pin
output serial [baud (
const-expr
)]
io-object-name
;
pin
An I/O pin. Serial input requires one pin and must specify IO_8. Serial
output also requires one pin and must specify IO_10.
baud (
const-expr
)
Specifies the bit rate. The expression
const-expr
can be 600, 1200, 2400, or
4800. The default is 2400. The firmware uses this value as a multiplier
based on the Series 3100 input clock or Series 5000 system clock. For
example, for a Series 3100 device at 10 MHz, baud(4800) yields 4800 bps; for
a Series 5000 device at 10 MHz, baud(4800) yields 9600 bps. The baud rate
scales proportionally with the input or system clock.