1.3 CAN-TP Library Implementation

The CAN protocol defines the Data Link and Physical layer. This is beneficial for vehicles to send information between devices through a CAN bus. While it is possible to send messages through a single CAN packet, messages may exceed the CAN packets maximum data length. CAN-TP is the Transport Protocol for handling these messages being sent over CAN/CAN-FD. The MCC library for CAN-TP implemented by Microchip follows the ISO 15765-2 specification. The implementation utilizes MCC Melody where the CAN-TP module can be configured in a project with a device that supports CAN/CAN-FD. The implementation supports a single instance of CAN-TP. For the correct functioning of the CAN-TP module, a CAN/CAN-FD and Timer module must be imported. Other additional configurations include Max Transmission Data Length, Default Separation time, Default Block size, pause on first frame, Message ID Mode, and Message ID.

  1. Max Transmission Data Length (bytes) - length of the packet being sent over CAN. CAN-TP will utilize the configuration set for the TX payload in the CAN-FD driver. This can only be configured differently for CAN-FD and not for CAN as the max is restricted to 8.

  2. Default Separation Time (ms) - Time between the frame packets being sent.

  3. Default Block Size - Number of Consecutive Frame packets before a new Flow Control is required.

  4. Pause on First Frame - Pause on First Frame makes the receiving device send a Flow Control wait frame.

  5. Message ID Mode - This is set as standard 11 bits or extended 29 bits. Selection here determines the ranges that can be used for Message ID.

  6. Message ID - Hexadecimal value in a specified range used for the sender to receiver(device to host).

When the necessary configurations are made code can be generated by clicking the generate button in the Project Resources tab. This will generate the firmware files for CAN-TP and the imported modules.

CAN-TP files generated and descriptions

can_tp.c, can_tp.h
  • Handles CAN-TP frames and message fragmentation and assembly.

  • Uses configurations from can_tp_config.h file.

  • Interacts with the can_tp_phy_adaptor files for interaction with CAN.

can_tp_phy_adaptor.c, can_tp_phy_adaptor.h
  • Interfaces with CAN/CAN-FD directly.

  • This adaptor layer allows the application to swap between instances of CAN Classic or CAN-FD without the need to change the application code.

can_tp_config.h
  • The configuration consists of the following:
    • Transmission Data Length.
      • This is the length of the CAN packet.

    • Message ID is Extended.
      • This tells whether the ID mode is extended.

    • Message ID Data.
      • This is the device to host ID.

    • Message ID Flow Control.
      • This is the same selection as ID data.

    • Default Separation Time.
      • Time between the frames being sent.

    • Default Block Size.
      • Number of frames to send before another Flow Control is required.

    • Pause on First Frame.
      • On First Frame sets whether a device will wait for a period of time.