FlexCase

CAN Guide

  • Send and receive CAN messages.

Prerequisites

Specifications

A summary of the CAN buses is provided below.

CANbus Item Specification
Common Buses CAN FD up to 5Mbps
ISO 11898-2, ISO 11898-5, SAE J2284 Compliant.
Tolerant to short circuit
Wake-on-CAN CAN FD up to 5Mbps
ISO 11898-2 Compliant.
CAN H/L tolerant to short circuit
Isolated CAN Supply 4.5-5.5V externally.
CAN FD up to 5Mbps
ISO 11898-2 Compliant.
CAN H/L tolerant to short circuit
Flashing Over CAN Currently, PCAN is the only device that supports flashing the FlexCase software over CAN (more info).

*Higher CAN FD speeds available with volume order

Note: The FlexCase does not have built-in termination resistors by default. A CAN bus requires two termination resistors, one at each end of the bus, to ensure proper communication.

Logic Active Control

  • CANbuses should to be enabled to be active. See the datasheet for the enable software pin.
  • Wake-on-CAN needs to be appropriately controlled. See the datasheet for the control pins and the power mode guide for the on/off process.

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.

Changing Baud Rates

To change the CAN baud rate, open the S32 Configuration Tool and select Can_43_FLEXCAN from the left panel to access the CAN configuration page, as shown in the screenshot below. Navigate to CanConfigSet -> CanController, where you will find settings for all six CAN buses (indexed 0-6). In the CanControllerBaudrateConfig section, you can adjust the Can Controller BaudRate(Kbps) to change the baud rate. After making your changes, click the “Update Code” button at the top left corner.

Enable & Configure CAN FD

To enable and configure CAN FD, go to the CanController tab and check the CAN FD ISO option, which enables the CAN FD format according to the ISO-11891 standard. Within the CanControllerBaudrateConfig section, click the + sign to add a CanControllerFdBaudrateConfig sub-section. Here, you can set the CAN FD baud rate as required. In the provided AudesseS32k3Unified.mex file, CAN0 is already configured for CAN FD with a baud rate of 500Kbps/2000Kbps. After making your changes, click the “Update Code” button at the top left corner.

MATLAB Software Features

The default settings for the FlexCase are to run the CAN0 bus at 500 kBaud (high speed CAN), and is capable of CANFD. The second bus CAN1 can be used if your FlexCase is communicating on two different busses or needs to integrated with sensors working on multiple baud rates.

The IDs and data payloads are arbitrarily chosen for this simple example. The send and receive blocks can be configured to communicate with the CANOpen, J1939, or other high-level CAN protocols.

If you have a DBC file for your application, you can use the CAN Pack and CAN Unpack Simulink blocks to automatically encode and decode CAN messages.

Third Party Hardware

There many devices that can be used to interface with the FlexCase if desired.

  • For basic receiving and transmitting of standard message formats, many consumer-grade USB-to-CAN converters can be purchased for less than $50, with varying degrees of software support.
    • This type of interface can be purchased from various sources, and provides basic functionality for hardware and software.
    • CANable is an open source design that interfaces with various free software packages.
  • A more advanced module is recommended if you are integrating with an existing vehicle, requiring full bus debugging, logging, and other advanced features.
    • The PCAN-USB is relatively inexpensive and very widely supported by various software, and has various useful accompanying software tools.
    • The Kvaser USB interfaces provide several advanced functions with high capacity, and fully supported free software modules.
    • Vector has a variety of premium CAN trace tools and software. These tools are expensive but usually have large discounts for research use.

If you are unsure which type of hardware is appropriate for your application, please contact us for additional advice.