# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ32MC10X -- UART

- 1
- 2
…
- 38
- 39
- 40
- 41
- 42
…
- 55
- 56

dsPIC33/PIC24 Family Reference Manual
DS70000582E-page 40  2009-2013 Microchip Technology Inc.
14.0 LIN/J2602 SUPPORT
The LIN/J2602 protocol transmits data in the form of small blocks, known as frames. Each frame
consists of a Break character with a delimiter, a Sync byte, a protected identifier and the data to
be transmitted (see Figure 14-1).
 Break Sequence: The Break sequence indicates the beginning of a new frame. A Break
sequence generated by the master node consists of a Start bit, followed by twelve bits of 0
and a break delimiter.
 Sync Byte: The Sync is a byte field loaded with the data value of 0x55. When the Auto-
Baud feature is enabled, the UART module uses the Sync byte to compute the baud rate of
the incoming data.
 Protected Identifier: The Protected Identifier contains the identifier and the identifier parity.
Figure 14-1: Frame Structure
14.1 Data Reception Using LIN/J2602 Protocol
When the LIN/J2602 protocol is used, the UART module receives data in the form of frames and
the incoming data is loaded into the receive buffer. For effective data reception, the BRG counter
should be loaded with the baud rate of incoming data.
The bit rate of the incoming data can be detected if the following occurs:
 The auto-baud feature is enabled
 The WAKE bit is set before setting the ABAUD bit
The UART module uses the Sync byte to compute the baud rate of the incoming data. If the
WAKE bit is set before setting the ABAUD bit, the Auto-Baud Rate Detection occurs on the byte
following the Break character. The module receives the Start bit of the Break character, the data
and the invalid Stop bit (which sets FERR), but the receiver waits for a valid Stop bit before receiv-
ing the next Start bit. No further reception can occur until a Stop bit is received. The WAKE bit is
automatically cleared once the Stop bit is received. After the fifth rising edge of the Sync
character is detected, the baud rate of the incoming data is loaded into the BRG counter and the
ABAUD bit is automatically cleared.
If the Auto-Baud feature is enabled without setting the WAKE bit, the delimiter is assumed to be
the first bit of the Sync byte instead of the Start bit. This results in erroneous baud rate calculation.
This happens because the receiver expects a Sync byte at the start of the reception. The LIN/
J2602 protocol, however, initiates the transmission with the Break character and the Sync byte
follows. Thus, the delimiter, which can range from one to four bits, is assumed to be the first low-
to-high transition on the RX line. Therefore, the delimiter acts as a first bit of the Sync byte instead
of the Start bit (see Figure 14-2).
UxRX
bit 0
bit 1
Start
bit 2
bit 3
bit 4
bit 5
bit 6
bit 7
Stop bit
Delimiter
Break Character Sync Byte
Identifier, Data
and Checksum
Note 1: Before data reception, the user application should load the BRG counter of the
UART module with a value approximate to the bit rate of the incoming data.
2: For LIN/J2602 support, the UART error interrupt (caused when FERR is set) may
need to be serviced before the (RX/TX) data interrupts. The UARTx Error Interrupt
Priority Level (UxEIP) must be raised, or the data Interrupt Priority Levels (UxRXIP
and UxTXIP) may be lowered.
Example for UART2 to raise the U2ErrInterrupt level:
 IPC7bits.U2RXIP = 4; //UART2 RX Interrupt Priority, mid-range
 IPC7bits.U2TXIP = 4; //UART2 TX Interrupt Priority, mid-range
 IPC16bits.U2EIP = 5; //UART2 Error Interrupt Priority set higher

- 1
- 2
…
- 38
- 39
- 40
- 41
- 42
…
- 55
- 56