Main Content

Configuring LIN Communications

Overview

The LIN communications architecture supports a single controller node and up to 16 peripheral nodes on a LIN network.

LIN nodes use message frames to exchange data. The message has two parts:

  • Frame header, generated by the controller node.

  • Frame response, which contains data generated by either peripheral node or a peripheral task on a controller node (but not both).

Configuring Your Model

First, study, and understand the LIN addressing system. See the “Message Filtering and Validation” topic in the TMS320F2803x Piccolo Local Interconnect Network (LIN) Module, Literature Number: SPRUGE2A.

Configure the LIN node in your model as a controller or peripheral node:

  1. Configure the Target Hardware Resources tab, as described in Configure Target Hardware Resources (Embedded Coder).

  2. In the Target Hardware Resources tab, select the Peripherals tab, and then select LIN.

  3. Set LIN mode to controller or peripheral.

If the LIN node is a controller node:

  • Add a LIN Transmit block to the model. This block enables the controller to generate message headers.

  • To send data, set the ID input and Tx ID Mask input to make Tx ID Match happen on this node.

  • To receive data, place LIN Receive block in the model. Set the Rx ID Mask input to make Rx ID Match happen on this node.

For example, to configure a model with a controller node that receives data from a peripheral node:

  • Add a LIN Transmit block and a LIN Receive block to the model.

  • In the Target Hardware Resources tab, configure the ID peripheral Task Byte.

  • For the LIN Transmit block, set the ID input.

  • For the LIN Receive block, set the Rx ID Mask input so that: Rx ID Mask = ID XOR peripheral Task ID Byte.

If the LIN node is a peripheral node:

  • To send data, place LIN Transmit block in the model. Set the ID input to match the LIN frame header issued by the remote controller. Set Tx ID Mask to make a Tx ID Match happen on this node.

  • To receive data, place LIN Receive block in the model. Set the Rx ID Mask input to make an Rx ID Match happen on this node.

For example, to configure a model with a peripheral node that transmits data to a controller node:

  • Add a LIN Transmit block to the model.

  • In the Target Hardware Resources tab, configure the ID byte or ID peripheral Task Byte (depending on the ID filtering option).

  • In the LIN Transmit block, set the ID input and Tx ID Mask input so that: Tx ID Mask = ID XOR (ID Byte or ID peripheral Task Byte).

Set the Data type and Data length values in your LIN Receive blocks to match the type and length of the transmitted data. These values enable the receive block reconstruct the data from the message frames.

Note

The LIN Transmit block inherits the data type and length from its input.