shown here sets the port
pins, the baud rate register, the transmit control
register, and then the receive control register.
Ther serial port uses RC7 to receive and RC6 to
transmit. The data direction for these pins must be
set as input for RC7/RX (TRISHC7=1;) and output for
RC6/TX (TRISC6=0;).
The Baud Rate Register is set to a value passed to
the function. This value is a constant defined in the
serial.h file and can be set to 9600, 19200, 57600, or
115200 baud.
The Transmit Status and Control Register configures
the transmitter and the only bit that is set is the
TXEN bit to enable the transmitter.
In the Receive Status and Control Register (RCSTA)
the receiver is enabled (CREN=1) and also the Serial
Port Enable Bit is set to enable both the transmitter
and receiver.