4-15
After initializing the serial port, you must also set up the interrupt service routine. The SCC2691 UART
takes up external interrupt /INT0 on the CPU, and you must set up the appropriate interrupt vector to
handle this. An interrupt service routine, scc_isr(), has been written to handle the interrupt, and it
enables/disables the interrupt as needed to transmit and receive data with the data buffers. So, after
initialization, you will need to make a call to do this:
int0_init(1, scc_isr);
By default, the SCC is disabled for both transmit and receive. Before using the port, you will need to
enable these functionalities.
When using RS232 in full-duplex mode, transmit and receive functions should both be enabled. Once this
is done, you can transmit and receive data as needed. If you do need to do limited flow control, the MPO
pin on the J1 header can be used for RTS. For a sample file showing RS232 full duplex communications,
please see ve_scc.c in the directory
tern\v25\samples\ve
.
RS485 is slightly more complex to use than RS232. RS485 operation is half-duplex only, which means
transmission does not occur concurrently with reception. The RS485 driver will echo back bytes sent to the
SCC. As a result, assuming you are using the RS485 driver installed on another TERN peripheral board,
you will need to disable receive while transmitting. While transmitting, you will also need to place the
RS485 driver in transmission mode as well. This is done by using scc_rts(1). This uses pin MPO (multi-
purpose output), found on the J1 header. While you are receiving data, the RS485 driver will need to be
placed in receive mode using scc_rts(0).
en485
Arguments: int i
Return value: none
This function sets the pin MPO either high (i = 1) or low (i = 0). The function scc_rts() actually has a
similar function, by pulling the same pin high or low, but is intended for use in flow control.
scc_send_e/scc_rec_e
Arguments: none
Return value: none
This function enables transmission or reception on the SCC2691 UART. After initialization, both of these
functions are disabled by default. If you are using RS485, only one of these two functions should be
enabled at any one time.
scc_send_reset/scc_rec_reset
Arguments: none
Return value: none
This function resets the state of the send and receive function of the SCC2691. One major use of these
functions is to disable send and receive. If you are using RS485, you will need to use this feature when
transitioning from transmission to reception, or from reception to transmission.
Transmission and reception of data using the SCC is in most ways identical to SER0 and SER1. The
functions used to transmit and receive data are similar. For details regarding these functions, please refer to
the previous section.
putser_scc
See: putsern
putsers_scc
See: putsersn