FlexCase
LIN Guide
- Local Interconnect Network(LIN) is a single-wire communication method for up to 19.2Kbit/s with a maximum length of 40meters.
- Each LIN bus should have only 1 commander(master) device/node and can have up to 15 responder(slave) devices/nodes.
Prerequisites
- Complete the install guide guide for a tutorial on connecting and flashing binaries
- Complete the Quick start guide.
Specifications
A summary of the LIN bus is provided below.
LIN Item | Specification |
---|---|
LIN Bus | Compliant to LIN 2.0, LIN 2.1, LIN 2.2, LIN 2.2A, and ISO 17987-4 EPL Max speed 19.2Kbit/s |
Wake on LIN | Upon receipt of a LIN message, FlexCase will turn on. |
Logic Active Control
- LIN should be enabled to be active. See the datasheet for the enable software pin.
- The wake-on-LIN signal will be active the first time FlexCase powers up. In order to be able to turn the device off see the datasheet for the control pins and the power mode guide for the on/off process.
- LIN on FlexCase can be configured as either commander or responder. In order to use the FlexCase as LIN commander, the Commander_EN pin should be driven as instructed in datasheet.
Software Configuration
The provided AudesseS32k3Unified.mex
file is pre-configured with most of the necessary device drivers for general use. However, in some cases, you may need to customize the device drivers based on your specific hardware requirements. Below, we have listed some possible custom configurations that might be needed. If you have other configuration needs, please contact us.
Note: The changes must be done in the S32 Configuration tool.
Initial Configurations
Open the configuration tool and in the Lin_43_LPUART_FLEXIO
Lin Node Type, Lin Channel BaudRate, and Lin hardware channel can be modified. For this tutorial purpose, we are setting up the (Commander)Master mode with 19.2Kbps baud rate and FLEXIO_OP_0 hardware channel.
The hardware channel can be either UART or FLEXIO.
In addition to the above shown setting, make sure to apply the appropriate setting in the following configuration tool options:
- Tx and Rx pins in the pinout, based on the info mentioned in the datasheet. (Either UART or FlexIO)
- Enable the Flexio_IRQn handler in Peripherals>Platform>Interrupt Controller.(The same applies to UART)
- FLEXIO clock should be enabled in Peripherals>Mcu>McuModuleConfiguration>McuModeSettingConf>McuPeripheral(The same applies to UART.)
- Flexio pins in Mcl configuration should be the same pins you are using in your Lin configuration. Peripherals>Mcl>Mcl Specific Configuration>FlexioCommon
MATLAB Software Features
As shown in the example, the master node can either send data frames or request the slave to respond. Physical ID, Checksum type, Response type, Data index, and data are the variables needed for sending a Lin frame. Blocks on the left are requesting data from the slave device, while the right side blocks are sending data to the slave device.
Note: Each Lin device has a dedicated physical ID between 0 to 59 and in some cases you can change/assign them.
Lin Get Status Block
The status of the Lin communication greatly matters for sending and receiving messages in a timely coordinated matter. Using the Lin_GetStatus function in Simulink, an indicator of the status of the Lin channel can be read and utilized.
The list of status indicators are as following:
- 0 – LIN_NOT_OK
- 1 – LIN_TX_OK
- 2 – LIN_TX_BUSY
- 3 – LIN_TX_HEADER_ERROR
- 4 – LIN_TX_ERROR
- 5 – LIN_RX_OK
- 6 – LIN_RX_BUSY
- 7 – LIN_RX_ERROR
- 8 – LIN_RX_NO_RESPONSE
- 9 – LIN_OPERATIONAL