DELPHI CORPORATION LIN to RS-232 Gateway Systems Analysis INterface Tool (SAINT) Users Guide Document Number TBD Version D, Draft 1 August 15, 2003 Copyright Delphi Corporation, 2003 Maintained by: Chris Spurrier Delphi Delco Electronics Systems 1800 East Lincoln Road Kokomo, IN 46904-9005 Phone: (765) 451-3645 christopher.spurrier@delphiauto.com
LIN to RS-232 Gateway 8/28/02 Page 1 of 21 SAINT Table of Contents 1 Introduction...3 1.1 Scope...3 1.2 Precedence...3 1.3 Definitions and Nomenclature...3 2 Overview...4 3 RS-232 Setup...5 3.1 Buffering and Flow Control...6 4 Message Format...7 4.1 Data Stream...7 4.2 Messages IDs...8 4.3 Gateway Messages...9 4.4 LIN Messages...12 5 Connectors...17 5.1 RS-232 Connector (J3-DB9F)...17 5.2 Flash programming connector...18 6 LEDs...19 7 Software Packages...20
LIN to RS-232 Gateway 8/28/02 Page 2 of 21 SAINT Revision A Draft 1 August 28, 2002 Initial release of the document. Revision Log Revision B Draft 1 October 10, 2002 Added more definition to document for various modes, etc. Added documentation for lin uartil monitor mode. Revision C Draft 1 December 04, 2002 Added documentation for lin trigger control commands. Revision D Draft 1 August 15, 2003 Modified lin baudrate command.
LIN to RS-232 Gateway 8/28/02 Page 3 of 21 SAINT 1 Introduction 1.1 Scope This document describes the use and operation of SAINT Gateway with LIN firmware. This document is proprietary to Delphi Automotive Systems Corporation and cannot be copied in whole or in part without the express written consent of Delphi Automotive Systems Corporation. 1.2 Precedence This document shall have precedence over any information in any other document. Between reference documents, the document with the later revision date shall have precedence. 1.3 Definitions and Nomenclature Gateway - abbreviation for LIN to RS-232 Gateway. SAINT - acronym for the gateway (Systems Analysis INterface Tool). Host - The computer which communicates to the gateway via RS-232 or USB. USB - Universal Serial Bus LIN - Local Interconnect Network Protocol
LIN to RS-232 Gateway 8/28/02 Page 4 of 21 SAINT 2 Overview This document describes the operation of the LIN to RS-232 Gateway. The gateway is often referred to as the SAINT gateway or simply SAINT. The following is a synopsis of gateway features: Allows host system to communicate on LIN bus. Performs timing, access, serialization, and error control. Configuration via host to gateway messages. LED status indicator array: 1. Power LED (flashing LED) 2. Bus Message LED (toggles during transmit of Gateway to Host message) 3. Message Trigger LED (toggles upon receiving a specified byte pattern) Gateway to host status / error messages. Software is easily updated via a flash connector. Will eventually be done through the USB bus. The following is a synopsis of requirements for use of the gateway: Connection to power, ground, and busses to be monitored RS-232 connection to host
LIN to RS-232 Gateway 8/28/02 Page 5 of 21 SAINT 3 RS-232 Setup The gateway uses the following RS-232 parameters: - 8 Data Bits - 1 Stop Bit - No Parity The gateway supported baud rate: 57600. Baud Rate 57600 The supported baud rate is sufficient for communicating with the Class2, Keyword, ACP, BEAN, E&C, LIN and slower CAN bus s. However, USB connection is recommended for high speed CAN communications.
LIN to RS-232 Gateway 8/28/02 Page 6 of 21 SAINT 3.1 Buffering and Flow Control Whenever the gateway receives a new message from the host, it will set the CTS line until the message can be processed. The host should not send data to the gateway while the CTS line is set. Due to the speed of the gateway processor, it is unlikely that the host will ever see the CTS line set. The gateway buffers 32 bytes to send to the host. The gateway polls the RS-232 transmitter in the main loop to send data to the host. In some cases, the RS-232 transmit buffer will overflow. This should occur only when receiving CAN or IIC messages at a very fast rate. This will cause an ERc_RSFull error to be generated and the data to be lost.
LIN to RS-232 Gateway 8/28/02 Page 7 of 21 SAINT 4 Message Format To minimize latency with the RS-232 link, all data is sent in binary form. The same data format is used to send and receive messages. The gateway supports bi-directional asynchronous communications. 4.1 Data Stream The host data stream is broken into messages. A message consists of a Message ID and one or more data bytes. The character FFh is used as an ESCAPE character to indicate the end of messages. There are three cases when an ESCAPE character is received. If the ESCAPE character is followed immediately by a second ESCAPE character, the following are true: The message is not yet complete. The pair of ESCAPE characters represents a single byte of message data of value FFh. If the ESCAPE character is followed immediately by a byte of value 00h, the following are true. The message is complete. Neither the FFh nor the 00h are part of the message. No more messages are ready to be sent. If the ESCAPE character is followed immediately by of any value other than FFh or 00h, the following are true: The message is complete. Neither the ESCAPE character nor the character following the ESCAPE character are part of the message. The value following the ESCAPE character is the message ID for a new message. This data stream format was chosen to allow arbitrary long messages (i.e. 4K Class 2 data blocks), to minimize the overhead to two bytes per message during peak traffic, and to immediately recognize the end of a message without having to wait for the next message to start. After a gateway reset, the gateway will ignore all data until it sees an ESCAPE character. Once it has received a valid EOM, it will recognize the following message.
LIN to RS-232 Gateway 8/28/02 Page 8 of 21 SAINT 4.2 Messages IDs Message IDs are one byte long and have the following general format: Type (CAN, BEAN, ACP,Class 2, IIC, etc) Command (Cmd=1) Tx (1) / Rx (0) Time Stamp (TS) Bits 3-7 bit 2 bit 1 bit 0 The upper nibble indicates the type of message. The following types are defined: Gateway (08) Keyword 82 (10h) Keyword 71 (18h) IIC (20h) Keyword 2000 (28h) IDB (30) ACP (38h) E&C (40h) J1708 (48h) CAN (50h) Class2 (60h) Class2 Block (68h) SPI (70h) BEAN1 (90h) BEAN2 (98h) LIN (B8h) Bits 3 to 7 identify the specific communication bus (i.e., Class 2, CAN bus, etc.). Bit 2 is used to designate a command or setup message when set to 1. Bit 1 is the transmit/receive bit with 1 designating transmit and 0 designating receive. Bit 0 is used to designate the Time Stamp. In general, report messages from the gateway use the same identifiers as commands to the gateway.
LIN to RS-232 Gateway 8/28/02 Page 9 of 21 SAINT 4.3 Gateway Messages 4.3.1 Gateway Commands (LIN V1.2) The SAINT - LIN Gateway supports the following commands: Header ID Data Description 08h 02h None Gateway Bus Receiver On (LIN) 08h 03h None Gateway Bus Receiver Off (LIN) 08h 80h None Perform Reset 08h 86h None Turn Time Stamp Information OFF 08h 87h None Turn Time Stamp Information ON 08h 88h None Turn Transmit Echo ON 08h 89h None Turn Transmit Echo OFF 08h 90h 63 bytes Send Periodic Messages 08h 91h None End Periodic Messages 08h 92h None Request Software Version 08h F0h 1 9 bytes Enable Gateway Trigger 08h F1h None Disable Gateway Trigger 4.3.1.1 Gateway Bus Receiver This command will enable/disable the LIN receiver to avoid receiving messages. The LIN transmitter is always enabled. 4.3.1.2 Reset This command will cause the gateway to do a complete cold start. The gateway will ignore the next message. 4.3.1.3 Time Stamp This command controls whether a 16-bit time stamp is appended to the end of the bus message reports. 4.3.1.4 Transmit Echo This command controls whether transmitted messages are echoed back to the host when they are sent. Echoed back messages will have their transmit bit set. 4.3.1.5 Send Periodic Messages (valid in master mode only!) This command will transmit up to six LIN messages periodically in Master mode only. See example below. Example for sending LIN Master periodic messages: 08 90 TT TT B8 +
LIN to RS-232 Gateway 8/28/02 Page 10 of 21 Message1 (length byte + identifier byte + 8 response bytes) + Message2 (length byte + identifier byte + 8 response bytes) + Message3 (length byte + identifier byte + 8 response bytes) + Message4 (length byte + identifier byte + 8 response bytes) + Message5 (length byte + identifier byte + 8 response bytes) + Message6 (length byte + identifier byte + 8 response bytes) Where TT is the periodic time in milliseconds from message to message (0001h - FFFFh), length byte is the length of the message (00h, 01h, 03h, 05h, 09h, or FFh), identifier byte is an acceptable LIN protocol identifier, and response bytes is the identifier response (2, 4, or 8 bytes). If a message only consists of an identifier then the length byte will be 01h and the response bytes must be filled in with zeros. If a message consists of an identifier and a two-byte response then the length byte will be 03h and the first two response bytes will be the valid response and the rest of the response bytes will be zeros. If a message consists of an identifier and a four-byte response then the length byte will be 05h and the first four response bytes will be the valid response and the rest of the response bytes will be zeros. If a message consists of an identifier and an eight-byte response then the length byte will be 09h and all eight of the response bytes will be the valid response. If the length byte for any message is set to 00h, that message is skipped. If the length byte of any message is set to FFh, that marks the end of the table if six messages are not provided and that message is not sent (table rolls over). It is the responsibility of the user to fill in the message table correctly. A gateway error will be generated if the length of the command message is invalid. The report for this command will only include the six message identifiers due to the length of the RS232 transmit buffer. 4.3.1.6 Software Version Request This command requests the gateway software version (ASCII) (LIN Vx.x). 4.3.1.7 Trigger (not valid in uartil mode or uartil monitor mode!) This command will cause the gateway to toggle the trigger LED upon receiving a specified byte pattern. LIN receive messages will consist of only 1 byte (identifier only), 2 bytes (2 byte identifier response), 3 bytes (identifier + 2 byte identifier response), 4 bytes (4 byte identifier response), 5 bytes (identifier + 4 byte identifier response), 8 bytes (8 byte identifier response) and 9 bytes (identifier + 8 byte identifier response) lengths. These are the only legal trigger mask values. A gateway error will be generated if the length of the command message is invalid. The report for this command will include the entire message. This feature is helpful for triggering an oscilloscope or arbitrary waveform generator.
LIN to RS-232 Gateway 8/28/02 Page 11 of 21 4.3.2 Gateway Reports The gateway will report a reset whenever one occurs. Most likely causes of reset are power on reset, host commanded reset, or gateway micro watchdog error. The gateway does a cold start on all resets (all information is lost). The gateway will also report error conditions with the Report Error message below. See section 4.3.2.1 for error code definitions. The gateway will also echo back all system commands. Header ID Description Data Bytes 08h 02h Report Gateway Bus Receiver On (LIN) None 08h 03h Report Gateway Bus Receiver Off (LIN) None 08h 80h Reset Occurred None 08h 82h Report Error 1 byte Error Code 08h 86h Report Time Stamp Information OFF None 08h 87h Report Time Stamp Information ON None 08h 88h Report Transmit Echo ON None 08h 90h Report Periodic Messages ON 6 LIN Message Identifiers 08h 91h Report Periodic Messages OFF None 08h F0h Report Gateway Trigger ON 1-9 bytes of Trigger Data 08h F1h Report Gateway Trigger OFF None 4.3.2.1 Gateway Error Codes Most error codes are related to sending data at the wrong rate (usually too fast). Code 80h 81h 82h 83h 84h Description System - Invalid message ID or Invalid Message (incorrect data, length, etc.) System - RS-232 Transmit Buffer Full System - UART Error (Overrun, etc.) System Received message is too long. System - Have not read previous message
LIN to RS-232 Gateway 8/28/02 Page 12 of 21 4.4 LIN Messages 4.4.1 LIN Commands and Command Reports LIN mode command (MASTER = 00h) (SLAVE = 01h) (MONITOR = 02h) (UARTIL = 03h) (UARTIL MON. = 04h) Byte 1 Byte 2 Byte 3 BCh 02h Mode LIN mode command report (MASTER = 00h) (SLAVE = 01h) (MONITOR = 02h) ( UARTIL = 03h) (UARTIL MON. = 04h) Byte 1 Byte 2 Byte 3 BCh 02h Mode LIN baud rate command (20.9k = 0Bh) to (2.4k = 60h) Baud rate = 1/(freq * 4.34us) Byte 1 Byte 2 Byte 3 BCh 04h Baud rate LIN baud rate command report (20.9k = 0Bh) to (2.4k = 60h) Baud rate = 1/(freq * 4.34us) Byte 1 Byte 2 Byte 3 BCh 04h Baud rate LIN slave received identifiers response command (response1 response9) (valid in slave mode only!) Byte 1 Byte 2 Bytes 3 Bytes 11 Bytes 12 Bytes 20 BCh 06h 1 - ID + [2,4,8] response bytes 2 - ID + [2,4,8] response bytes Bytes 21 Bytes 29 Bytes 30 Bytes 38 Bytes 39 Bytes 47 Bytes 48 Bytes 56 3 - ID + [2,4,8] response bytes 4 - ID + [2,4,8] response bytes 5 - ID + [2,4,8] response bytes 6 - ID + [2,4,8] response bytes Bytes 57 Bytes 61 Bytes 62 Bytes 64 Bytes 65 Bytes 67 7 - ID + [2,4] response bytes 8 - ID + [2] response bytes 9 - ID + [2] response bytes
LIN to RS-232 Gateway 8/28/02 Page 13 of 21 LIN slave received identifiers response command report (response1 response9) (valid in slave mode only!) Byte 1 Byte 2 Byte 3 Byte 4 BCh 06h 1 - ID 2 - ID Byte 5 Byte 6 Byte 7 Byte 8 3 - ID 4 - ID 5 - ID 6 - ID Byte 9 Byte 10 Byte 11 7 - ID 8 - ID 9 - ID LIN periodic messages off if trigger - enable command / command report Byte 1 Byte 2 BCh 08h LIN periodic messages off if trigger - disable command / command report Byte 1 Byte 2 BCh 09h These commands control whether to turn off periodic messages, if activated, when a trigger match has been made between a received message and the trigger mask setup with Gateway command F0h Enable Gateway Trigger. These commans are only valid if in LIN master mode.
LIN to RS-232 Gateway 8/28/02 Page 14 of 21 4.4.2 Transmitted LIN - UARTIL Messages (Master UARTIL modes only) LIN Master transmit (identifier only) Byte 1 Byte 2 B8h Identifier LIN Master transmit (identifier + 2 byte response) Byte 1 Byte 2 Byte 3 Byte 4 B8h Identifier byte 1 byte 2 LIN Master transmit (identifier + 4 byte response) Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 B8h Identifier byte 1 byte 2 byte 3 byte 4 LIN Master transmit (identifier + 8 byte response) Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte 9 Byte 10 B8h Identifier byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 byte 7 byte 8 LIN Uart transmit (1 to 176 data bytes) Byte 1 Byte 2 Byte 177 B8h Data byte 1 Data byte 176
LIN to RS-232 Gateway 8/28/02 Page 15 of 21 4.4.3 Received LIN Messages LIN Gateway Transmit Echo (if echo enabled) Byte 1 Byte 2 Byte N Byte N + 1 BAh Data,Cksum, etc. Completion code LIN Gateway Transmit Echo with Timestamp (if echo and timestamp enabled) Byte 1 Byte 2 Byte N Byte N + 1 Byte N + 2 Byte N + 3 BBh Data,Cksum, etc. Completion code Timestamp MSB Timestamp LSB LIN Gateway Receive Byte 1 Byte 2 Byte N Byte N + 1 B8h Data,Cksum, etc. Completion code LIN Gateway Receive with Timestamp (if timestamp enabled) Byte 1 Byte 2 Byte N Byte N + 1 Byte N + 2 Byte N + 3 B9h Data,Cksum, etc. Completion code Timestamp MSB Timestamp LSB Completion Code Definition: Bits 7-5 100 - Lin transmit queue overrun - sending data to fast 011 - Lin corrupt byte - invalid stop bit 010 - Lin last received byte not processed - sending data to fast 001 - Lin receive queue overrun - message received was to long Bit 3 set - Lin slave not responding error Bit 2 set - Lin identifier parity error
LIN to RS-232 Gateway 8/28/02 Page 16 of 21 Bit 1 set - Lin checksum error Bit 0 set - Lin bit error Note1: All Lin transmit errors will be reflected in the next transmitted or received message completion code. All Lin receive errors will be reflected in that received message s completion code. Note2: If in UARTIL MONITOR MODE (mode = 04h) and an error occurs the gateway will disable the LIN receiver and issue a Gateway Bus Receiver Off report (08 03). This is to insure that the LIN receiver will not stall on erroneous bus states (i.e. bus pulled low after reset for a long period of time). If this occurs the user must re-enable the LIN receiver with a Gateway Bus Receiver On Command (08 02) before receiver communications will resume.
LIN to RS-232 Gateway 8/28/02 Page 17 of 21 5 Connectors The gateway uses two connectors. One connector is for the RS-232 link and is DB9F. The second connector is a DB9M for the CAN bus (low speed, medium speed, and high speed), Class 2 bus, Keyword, LIN, power, and ground. The following pin outs are used: 5.1 RS-232 Connector (J3-DB9F) A straight pass cable should be used to connect the gateway to the host computer. DE-9s Pin # Use 2 TX to Host 3 RX from Host 8 CTS 6 DSR 5 GND 5.2 Bus and Power Connector (J4-DB9M) The SAINT boards Bus, Power, and Ground pins are compatible with the Demon. DE-9p Pin # Use 1 Ground 2 SW CAN H 3 LS CAN L 4 LS CAN H 5 HS CAN H 6 HS CAN L 7 CLASS2 8 LIN / KEYWORD 9 +12V
LIN to RS-232 Gateway 8/28/02 Page 18 of 21 5.3 Flash programming connector Note: the long-term goal is to Flash using the USB connector. Connector J2 is used with an external connector the intended application of this port is the flash programming of a product. The pin out of the connector J2 flash programming connector - is as follows: Pin # Mnemonic Use / description Line up the connector label with the board pin label. Osc1 Osc2 External (to SAINT) oscillator External (to SAINT) oscillator Vdd Already connected to +5V on SAINT board Vss Already grounded
LIN to RS-232 Gateway 8/28/02 Page 19 of 21 6 LEDs Four LEDs are used by the gateway. These LEDs are: LED # Purpose 4 NC (No Connection) 3 Trig (Toggled on specified message) 2 Pow (SAINT powered up) 1 Bus (Toggles when transmitting an RS232 message)
LIN to RS-232 Gateway 8/28/02 Page 20 of 21 7 Software Packages The following table lists the latest firmware releases for the SAINT board. Name Hardware Version Date Description LIN_V10.HEX 1.4 08/28/2002 Initial Release LIN_V11.HEX 1.4 10/10/02 Added uartil monitor mode Added Gateway bus Comm. On/Off LIN_V12.HEX 1.4 12/04/02 Added Trigger Control LIN_V13.HEX 1.4-1.5 08/15/03 Modified Lin Baudrate Command