XC886/888CLM
Serial Interfaces
User’s Manual
12-32
V1.3, 2010-02
Serial Interfaces, V 1.0
12.3.1
General Operation
12.3.1.1
Operating Mode Selection
The operating mode of the serial channel SSC is controlled by its control register CON.
This register has a double function:
•
During programming (SSC disabled by CON.EN = 0), it provides access to a set of
control bits
•
During operation (SSC enabled by CON.EN = 1), it provides access to a set of status
flags.
The shift register of the SSC is connected to both the transmit lines and the receive lines
via the pin control logic. Transmission and reception of serial data are synchronized and
take place at the same time, i.e., the same number of transmitted bits is also received.
Transmit data is written into the Transmitter Buffer register (TB) and is moved to the shift
register as soon as this is empty. An SSC master (CON.MS = 1) immediately begins
transmitting, while an SSC slave (CON.MS = 0) will wait for an active shift clock. When
the transfer starts, the busy flag CON.BSY is set and the Transmit Interrupt Request line
(TIR) will be activated to indicate that register TB may be reloaded again. When the
programmed number of bits (2...8) have been transferred, the contents of the shift
register are moved to the Receiver Buffer register (RB) and the Receive Interrupt
Request line (RIR) will be activated. If no further transfer is to take place (TB is empty),
CON.BSY will be cleared at the same time. Software should not modify CON.BSY, as
this flag is hardware controlled.
Note: The SSC starts transmission and sets CON.BSY minimum two clock cycles after
transmit data is written into TB. Therefore, it is not recommended to poll CON.BSY
to indicate the start and end of a single transmission. Instead, interrupt service
routine should be used if interrupts are enabled, or the interrupt flags IRCON1.TIR
and IRCON1.RIR should be polled if interrupts are disabled.
Note: Only one SSC can be the master at a given time.
The transfer of serial data bits can be programmed in a number of ways:
•
The data width can be specified from 2 to 8 bits
•
A transfer may start with either the LSB or the MSB
•
The shift clock may be idle low or idle high
•
The data bits may be shifted with the leading edge or the trailing edge of the shift
clock signal
•
The baud rate may be set within a certain range depending on the module clock
•
The shift clock can be generated (MS_CLK) or can be received (SS_CLK)
These features allow the SSC to be adapted to a wide range of applications requiring
serial data transfer.
*