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

    TX Only mode

  1. 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

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