English
Language : 

PIC18F14K22LIN Datasheet, PDF (32/62 Pages) Microchip Technology – 20-Pin Flash Microcontrollers 20-Pin Flash Microcontrollers
PIC18F14K22LIN
6.1.2
EUSART ASYNCHRONOUS LIN
RECEIVER
6.1.2.1 Asynchronous Reception Setup:
1. Initialize the SPBRGH:SPBRG register pair and
the BRGH and BRG16 bits to achieve the
desired baud rate (see Register 6-3).
2. Enable the serial port by setting the SPEN bit
and the RX/DT pin TRIS bit. The SYNC bit must
be clear for asynchronous operation.
3. If interrupts are desired, set the RCIE interrupt
enable bit and set the GIE and PEIE bits of the
INTCON register.
4. Enable reception by setting the CREN bit.
5. The RCIF interrupt flag bit will be set when a
character is transferred from the RSR to the
receive buffer. An interrupt will be generated if
the RCIE interrupt enable bit was also set.
6. Read the RCSTA register to get the error flags
and, if 9-bit data reception is enabled, the ninth
data bit.
7. Get the received 8 Least Significant data bits
from the receive buffer by reading the RCREG
register.
8. If an overrun occurred, clear the OERR flag by
clearing the CREN receiver enable bit.
TABLE 6-2: REGISTERS ASSOCIATED WITH ASYNCHRONOUS RECEPTION
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Reset
Values
on page
BAUDCON ABDOVF RCIDL
0
0
BRG16
—
WUE ABDEN
39
INTCON GIE/GIEH PEIE/GIEL TMR0IE INT0IE RABIE TMR0IF INT0IF RABIF —(1)
IPR1
—
ADIP
RCIP
TXIP
1
CCP1IP TMR2IP TMR1IP —(1)
PIE1
—
ADIE
RCIE
TXIE
0
CCP1IE TMR2IE TMR1IE —(1)
PIR1
—
ADIF
RCIF
TXIF
0
CCP1IF TMR2IF TMR1IF —(1)
RCREG EUSART Receive Register
—(1)
RCSTA
SPEN
0
0
CREN
0
FERR OERR
0
38
SPBRG
EUSART Baud Rate Generator Register, Low Byte
—(1)
SPBRGH EUSART Baud Rate Generator Register, High Byte
—(1)
TRISC
TRISC7
—
TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 —(1)
TXSTA
0
0
TXEN
0
SENDB BRGH TRMT
0
37
Legend: — = unimplemented locations read as ‘0’. Shaded cells are not used for asynchronous reception.
Note 1: Information about these registers can be found in “PIC18(L)F1XK22 Data Sheet” (DS41365).
DS41580A-page 36
Preliminary
 2011 Microchip Technology Inc.