MCUSW
CAN Profiling Application

Introduction


This application measures the CPU cycles required for transmission of N number of packets for a given baud-rate and CAN configurations.

Simulates transmission of N number of CAN messages (64 bytes, CAN FD message) the received messages (when in loopback mode) is copied to local variable simulating a copy of the message by communication stack.

Table below list SoC/Cores on which this demo application is tested

SoC Host Core Comments
J721E MCU 1 0 & MCU 2 1 None
J7200 MCU 1 0 & MCU 2 1 None

Dependencies

This application depends on multiple components and are detailed in sections below

  1. FREERTOS: Uses Task, semaphore, Interrupt Handling HWI and Profiling Utility.
  2. MCAL
    • CAN Driver
    • Dio Driver to setup pins required for TX/RX
  3. MCAL BSW Stubs Stubs at (SDK Install Directory)/mcusw/mcuss_demos/Bsw_Stubs are used. Functions CanIf_Init (), CanIf_TxConfirmation () and CanIf_RxIndication () are required.
  4. MCAL Configurations CAN & DIO Configurations at (SDK Install Directory)/mcusw/mcuss_demos/mcal_config are used.

Back To Top


Flow Chart

demo_can_profile_flowchart.png
CAN Profiling Application

Back To Top


Customizing Examples Application

The profiling application is configured to operate in internal loop-back and interrupt mode by default. This application supports the following configurations:

  1. Internal loopback
    • Polling mode
    • Interrupt mode
  2. External loopback
    • Polling mode
    • Interrupt mode
  3. Tx only
    • Polling mode
    • Interrupt mode
  4. Rx only
    • Polling mode
    • Interrupt mode

The below table lists the configuration changes required to change mode. Please ensure to recompile post modifications. We will first go over the different modes and then on the underlying implementation of polling or interrupts.

NOTE: Location of the below flags will change to MCU2_1 specific paths in case application is running on MCU2_1 instead of MCU1_0. Replace "mcu1_0" in the path with "mcu2_1".

Operating modes

TX Only

For TX Only Flag Value Location
APP_INSTANCE_1_INST_IN_CFG_ONLY STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_LOOPBACK_ENABLE STD_OFF mcusw\mcuss_demos\mcal_config\Can_Demo_Cfg\output\generated\soc\j72xx\mcu1_0\include\Can_Cfg.h
CAN_EXT_LOOPBACK STD_OFF mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_TX_ONLY_MODE STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h

This application would transmit CAN FD messages with extended ID (0xC0) at nominal-rate of 1 Mbps, data-rate at 5 Mbps

RX Only

For RX Only Flag Value Location
APP_INSTANCE_1_INST_IN_CFG_ONLY STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_LOOPBACK_ENABLE STD_OFF mcusw\mcuss_demos\mcal_config\Can_Demo_Cfg\output\generated\soc\j72xx\mcu1_0\include\Can_Cfg.h
CAN_EXT_LOOPBACK STD_OFF mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_TX_ONLY_MODE STD_OFF mcusw\mcuss_demos\profiling\can\can_profile.h

This application setup to receive CAN FD messages with extended ID (0xC0) at nominal-rate of 1 Mbps, data-rate at 5 Mbps

Internal Loopback (default)

For Internal Loopback (default) Flag Value Location
APP_INSTANCE_1_INST_IN_CFG_ONLY STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_LOOPBACK_ENABLE STD_ON mcusw\mcuss_demos\mcal_config\Can_Demo_Cfg\output\generated\soc\j72xx\mcu1_0\include\Can_Cfg.h
CAN_EXT_LOOPBACK STD_OFF mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_TX_ONLY_MODE X mcusw\mcuss_demos\profiling\can\can_profile.h

No additional connections / setup is required in this mode

External Loopback

For External Loopback Flag Value Location
APP_INSTANCE_1_INST_IN_CFG_ONLY STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_LOOPBACK_ENABLE STD_OFF mcusw\mcuss_demos\mcal_config\Can_Demo_Cfg\output\generated\soc\j72xx\mcu1_0\include\Can_Cfg.h
CAN_EXT_LOOPBACK STD_ON mcusw\mcuss_demos\profiling\can\can_profile.h
CAN_TX_ONLY_MODE X mcusw\mcuss_demos\profiling\can\can_profile.h

This application is setup to transmit on MCAN4 and receive on MCAN9 when running on MCU2_1. While running on MCU1_0 it transmits on MCU MCAN0 and receive on MCU MCAN1. Additional setup is needed, connect CANH <-> CANH, CANL <-> CANL and GND <-> GND of the respective CANs. i.e. while running on MCU1_0, MCU MCAN0 and MCU MCAN1 should be connected and while running on MCU2_1, MCAN4 and MCAN9 should be connected by 3 jumper wires.

Underlying implementation

Interrupt mode (default)

For Interrupts (default) Flag Value Location
CAN_TX_POLLING STD_OFF mcusw/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j72xx/mcu1_0/include/Can_Cfg.h
CAN_RX_POLLING STD_OFF mcusw/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j721e/mcu1_0/include/Can_Cfg.h
CANIF_TX_POLLING STD_OFF mcusw/mcuss_demos/Bsw_Stubs/CanIf/inc/CanIf_Cbk.h
CANIF_RX_POLLING STD_OFF mcusw/mcuss_demos/Bsw_Stubs/CanIf/inc/CanIf_Cbk.h

Polling mode

For Polling Flag Value Location
CAN_TX_POLLING STD_ON mcusw/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j72xx/mcu1_0/include/Can_Cfg.h
CAN_RX_POLLING STD_ON mcusw/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j72xx/mcu1_0/include/Can_Cfg.h
CANIF_TX_POLLING STD_ON mcusw/mcuss_demos/Bsw_Stubs/CanIf/inc/CanIf_Cbk.h
CANIF_RX_POLLING STD_ON mcusw/mcuss_demos/Bsw_Stubs/CanIf/inc/CanIf_Cbk.h

Processing type for controller

In the mcusw/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j72xx/mcu1_0/src/Can_Cfg.c change the Can Rx Processing Type and Can Tx Processing Type in the Can_ControllerStruct_PC structure from CAN_TX_RX_PROCESSING_INTERRUPT to CAN_TX_RX_PROCESSING_POLLING. The above needs to be done for all controllers used (2 in case of MCU1_0 and 4 in case of MCU2_1). Without this change the application will not work!

Batch processing in polling

To enable polling mode with polling (optional), you can also change the following flag:

For batch processing in polling Flag Value Location
CAN_BATCH_PROCESSING_POLLING STD_ON mcusw/mcuss_demos/profiling/can/can_profile.h

Back To Top


Test Setup / Configurations used

Intenal Loopback mode

  1. Supported EVM / SoC
    Can_Profiling_CanLoopbackMode.png
    Loopback Setup

External Loopback mode

  1. Supported EVM / SoC
    External Loopback Setup

For MCU1_0 core testing two CAN instances are need MCAN0 and MCAN1. MCAN0 & MCAN1 instances are available on J721EXCP01EVM board.

MCAN0 instance at J30 4-pin header:

  1. MCU_MCAN0_H (">" Mark on male header)
  2. DGND
  3. MCU_MCAN0_L
  4. MCU_MCAN0_WAKE
J30 4-pin header pinout

MCAN1 instance at J31 3-pin header:

  1. MCU_MCAN1_H (">" Mark on male header)
  2. DGND
  3. MCU_MCAN1_L
J31 3-pin header pinout

We need to loop these two header J31, J30 with jumper wire.

MCU_MCAN0_H <—Jumper Wire—> MCU_MCAN1_H

MCU_MCAN0_L <—Jumper Wire—> MCU_MCAN1_L

Now you can proceed with CAN external loopback testing.

TX Only mode

CAN_HIGH of all the nodes on the bus shall be connected together. Similary CAN_LOW of all the nodes on the bus shall be connected together.

Can_Profiling_CanTxOnlySetup.png
DRA80X TxOnly Setup
canbootapp_j721e_can_tx_setup_closeup.png
J721E TxOnly Setup

PCAN View application

We need to download the PCAN View software on system. Download

PCAN View application Configuration

For configuration of PCAN View application 3 parameter you have to set

  1. Clock Frequency - 80 Mhz
  2. Nominal Bit Rate - 1 MBit/s
  3. Data Bit Rate - 5 MBit/s

The nominal bit rate is a section of CAN frame i.e. ID, CRC, ACK etc. The data bit rate is the data section within the CAN frame.

Filter Settings set to Extended

These parameter you have to set in Connect floating windows.

Click on > Arrow to configure Data Bit Rate

The data bit rate has to be set in such a way that the sample point is in the range of more than 75%.

You can refer below provided value to achieve the same.

In Manage Bit Rate window in Data section you have to add new Bit rate

Parameter Value
Caption 5 MBit/s
Prescaler 4
tseg1 2
tseg2 1
sync Jump width 1

Now you can proceed with CAN TX testing.

Back To Top


Early CAN response

J721E and J7200

This application can be used to profile early CAN response. In our validation, we used J721E Beta EVM and oscilloscope to monitor the time interval between Power On (MCU_PORZ_OUT signal, TP117) and CAN-H line toggle (header J30) on the EVM Common Processor Board. Detailed steps are listed below

  1. Build SBL using the “sbl_cust_img”, according to the SBL build instructions Refer SBL build instructions. This gives the minimum time spent in the bootloader phase for booting an application running on the R5 core in the MCU domain, without having to initialize any extra clocks or cores in the MAIN domain.
    1. goto (SDK Install Directory)/pdk_jacinto_07.x.x/packages/ti/build
    2. make sbl_cust_img BOARD=j72xx_evm SOC=j72xx -sj 
    3. sbl_cust_img_mcu1_0_release.tiimage would be available in (SDK Install Directory)/packages/ti/boot/sbl/binary/j72xx_evm/cust/bin/sbl_cust_img_mcu1_0_release.tiimage
    4. rename sbl_cust_img_mcu1_0_release.tiimage to tiboot3.bin
  2. NOTE: For support of Early CAN response with the fastest boot time (with NO prints enabled), you can pre-configure the SBL flags before building sbl_cust_img by modifying the CUST_SBL_TEST_FLAGS in the file (SDK Install Directory)/pdk_jacinto_07.x.x/packages/ti/boot/sbl/sbl_component.mk. Just search for this line and un-comment it (and comment out similar lines above it), then save and build sbl_cust_img:
    1. #CUST_SBL_TEST_FLAGS =" -DSBL_USE_DMA=0 -DSBL_LOG_LEVEL=1 -DSBL_SCRATCH_MEM_START=0x41cc0000 -DSBL_SCRATCH_MEM_SIZE=0x40000 -DSBL_ENABLE_PLL -DSBL_ENABLE_CLOCKS -DSBL_SKIP_MCU_RESET -DBOOT_OSPI -DSBL_ENABLE_DEV_GRP_MCU -DSBL_HLOS_OWNS_FLASH -DSBL_SKIP_PINMUX_ENABLE -DSBL_SKIP_LATE_INIT -DSBL_USE_MCU_DOMAIN_ONLY" 
  3. Build this application can_profile_app Refer MCUSW demo build instructions. Ensure this application is configured for TX only Refer can_profile_app config for tx only mode. Add the flag setting MCUSW_UART_ENABLE=false to the command-line build to enable the shortest possible time for Early CAN response (disables all UART output).
  4. Rename mcusw\binary\can_boot_app_mcu_rtos\bin\j72xx_evm\can_boot_app_mcu_rtos_mcu1_0_release.appimage to app
  5. Flash the custom SBL bootloader image (tiboot3.bin) to the OSPI flash at 0x0, as given in the OSPI flashing instructions
  6. Flash the SYSFW binary ( tifs.bin , available at (SDK Install Directory)/packages/ti/drv/sciclient/soc/Vx/tifs.bin) to the OSPI flash at 0x80000, as given in the OSPI flashing instructions
  7. Flash the app to the OSPI flash at 0x100000, as given in the OSPI flashing instructions
  8. Change DIP switches on the EVM to OSPI flash boot with NO SoC BIST functions performed, as shown below:
c_ug_evm_j721e_evm_ospi_early_can.png
J721E Beta EVM : Bootmode DIP switch settings for Early CAN response measurement
  1. Prepare to measure the time difference with an oscilloscope and two probes, between the MCU_PORZ_OUT signal on the J721E Beta SOM (TP117), and the CAN-H line (first pin) of the J30 CAN bus header on the J721E
  2. Configure the oscilloscope to trigger off of the rising edge of the MCU_PORZ_OUT signal (TP117 on the SOM board of Beta EVM), use the MCU PORz press-button (SW7) to reset/restart the EVM
  3. Measure the time difference between the two signals to get the CAN response time from RESET.
can_profile_app_mcu_power_point.png
J721E Beta EVM : MCU_PORZ_OUT
can_profile_app_can_connection.jpg
J721E Beta EVM : CAN Connector

To minimize latecies due to prints, the prints in this application could be minimized by turning OFF the flag CAN_INITIAL_PRINT_DISABLE_BEFORE_CAN_RESPONSE.

Back To Top


Steps to run with CCS

  1. Build the demo application as detailed in User Guide
  2. Steps to run is detailed in User Guide

Back To Top


Document Revision History

Revision Date Author Description Status
0.1 24 Dec 2018 Sujith S Initial Version Under Review
0.2 13 Jan 2019 Sunil M S Updated logs and setup picture (MCAL-2661) Approved
0.3 16 Jul 2019 Sujith S Added logs for J721E Approved
0.4 8 Aug 2019 Sunil M S Updates profile numbers for release 00.09.01 Approved
0.5 16 Oct 2019 Sujith S & Karan S Updates profile numbers for release 01.00.00 & Added option to change operating mode Approved
0.6 4 Feb 2020 Jonathan Bergsagel Updated measurement details for CAN response time Approved
0.7 6 Feb 2020 Sunil M S Updated output logs and performance measurement Approved
0.8 7 Feb 2020 Karan S Updated can profile app logs for mcu2_1 Approved
0.9 17 Feb 2020 Sujith S Re Organized the document Approved
1.0 28 May 2020 Jonathan Bergsagel Added further details for fastest CAN response time Approved
1.1 4 Jun 2020 Karan S Added details on polling mode in CAN profile app Approved
1.2 02 Nov 2020 Nikki S J7200 updated Approved
1.3 22 Jun 2020 Nikki S 1.03.03 Release Updates Approved