This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-J721S2: How to config mcu can fd baudrate and it's speed ?

Part Number: PROCESSOR-SDK-J721S2
Other Parts Discussed in Thread: TDA4VL, AM68

Tool/software:

Hi Teams,

I am debugging the mcu can function with this code

pdk_j721s2_10_00_00_27\packages\ti\csl\example\mcan\mcanEvmLoopback\mcan_evm_loopback_app_main_k3.c
I chage the bit times as below.
static int32_t App_mcanConfig(uint32_t mcanInstAddr, bool enableInternalLpbk)
{
/* Initialize bit timings
     * Configuring 1Mbps and 5Mbps as nominal and data bit-rate respectively */
bitTimes
+ bitTimes.nomRatePrescalar = 0x2U;
+ bitTimes.nomTimeSeg1 = 0x63U;
+ bitTimes.nomTimeSeg2 = 0x16U;
+ bitTimes.nomSynchJumpWidth = 0x16U;
+ bitTimes.dataRatePrescalar = 0x2U;
+ bitTimes.dataTimeSeg1 = 0x15U;
+ bitTimes.dataTimeSeg2 = 0x4U;
+ bitTimes.dataSynchJumpWidth = 0x4U;

}
I am using python to receive the can fd message.
        bus = can.ThreadSafeBus(interface='pcan', channel='PCAN_USBBUS1', can_filters=filters,
        f_clock_mhz=80,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4, fd=True
mcu uart logs
1)  the python receive can message since not correct.  "RX recv: Timestamp: 1733970171.484433        ID: 0004    S Rx E              DL:  4    01 00 7f 00"
This look like some kind of error message. What it this stand for ?
2) where is the Nominal bit rate kbits/  ?  Date bit rate kbit/s ?
3) which register address is can fd baud config ?
  • Hello,

    Please follow the FAQ to set the bit rates https://e2e.ti.com/support/processors-group/processors/f/processors-forum/920090/faq-tda4vm-can-how-is-bit-rate-calculated-for-can

    What is the other end on the CAN bus ? It also should be configured with same Nominal and data bit rates.

    Regards

    Tarun Mukesh

  • Hi Tarun,

    I have check the  mcan_evm_loopback_app_main_k3.c  bitTimes as below.

    nominal bit rate

    data bit rate

    We using  4. Loopback - external transmission and reception

    [2024-12-12 11:34:35] Starting Application...
    [2024-12-12 11:34:36] Available MCAN Module for usage:
    [2024-12-12 11:34:36] MCAN Clock Configuration Successful.
    [2024-12-12 11:34:36] MCAN Node Type:
    [2024-12-12 11:34:36] 1. Transmitter Side.
    [2024-12-12 11:34:36] 2. Receiver Side.
    [2024-12-12 11:34:36] 3. Loopback - no external transmission/reception
    [2024-12-12 11:34:36] 4. Loopback - external transmission and reception
    [2024-12-12 11:34:36] Enter type of the node:

    Physcial connect  EVM board CAN0 + CAN1 + PCAN-FD.  ( PC with python tool to receive can message)

  • Hi  Tarun,

    I am looking for mcu can relative detailed hardware register  description. In  the "Technical Reference Manual J721S2/TDA4VE/TDA4AL/TDA4VL/AM68 Processors Silicon Revision 1.0 Texas Instruments Families of Products"  only the address , but no detail register description . 

    Can you tell me where I can down the document ?

  • Hello,

    When you download TRM from ti.com you will have ZIP folder.In the same ZIP folder you can see registers

    https://www.ti.com/lit/zip/spruj28

    Regards

    Tarun Mukesh

  • Hi Tarun,

     "RX recv: Timestamp: 1733970171.484433        ID: 0004    S Rx E              DL:  4    01 00 7f 00"

    The rx message indicate is a Error Frame.

    MSG: ID 0004 

    ECC register SJA1000 (Error Code Capture), bits 6 and 7 (ERRC0, ERRC1)

    4: Stuff error

    https://docs.peak-system.com/API/PCAN-Basic.Net/html/d8b8c576-cc90-4757-a914-4a503f9553d1.htm

    Do you know how to fix the "4: Stuff error"  code ?

  • Hello

    For Stuff Error

    • Node type: Rx
    • Description: More than 5 equal bits in a sequence have occurred in a part of a received message where this is not allowed.
    • Check if all the nodes on the bus have same bit-rate.

    Regards

    Tarun Mukesh

  • Hi Tarun,

    • Check if all the nodes on the bus have same bit-rate.

    Do you mean PCAN viewer or python can fd setting ?

    How do you verify PROC118 001 J721S2XSOMG01EVM (processor board ) +PROC079 001 J721EXCP01EVM (daughter card ) can fd function ?

  • Hello,

    + bitTimes.nomRatePrescalar = 0x2U;
    + bitTimes.nomTimeSeg1 = 0x63U;
    + bitTimes.nomTimeSeg2 = 0x16U;
    + bitTimes.nomSynchJumpWidth = 0x16U;
    + bitTimes.dataRatePrescalar = 0x2U;
    + bitTimes.dataTimeSeg1 = 0x15U;
    + bitTimes.dataTimeSeg2 = 0x4U;
    + bitTimes.dataSynchJumpWidth = 0x4U;

    We calculate based on the values provided in the code as per  https://e2e.ti.com/support/processors-group/processors/f/processors-forum/920090/faq-tda4vm-can-how-is-bit-rate-calculated-for-can

    It looks like you want to use Nominal bit rate as 500 kbps and Data bit rate as 2 Mbps but your configured values are not meeting for 80MHz clock.

    Regards

    Tarun Mukesh

  • Hi Tarun,

    After applied below seting to application.

        bitTimes.nomRatePrescalar   = 0x7U;
        bitTimes.nomTimeSeg1        = 0x5U;
        bitTimes.nomTimeSeg2        = 0x2U;
        bitTimes.nomSynchJumpWidth  = 0x1U;
        bitTimes.dataRatePrescalar  = 0x1U;
        bitTimes.dataTimeSeg1       = 0x3U;
        bitTimes.dataTimeSeg2       = 0x2U;
        bitTimes.dataSynchJumpWidth = 0x1U;
    4. Loopback - external transmission and reception
    I can see the can frame on PCAN-View,  But the ms id : 004h is not maching the code setting "Message ID: 0x100000"
    What is the real can message id ?
     
  • Hello,

        bitTimes.nomRatePrescalar   = 0x7U;
        bitTimes.nomTimeSeg1        = 0x5U;
        bitTimes.nomTimeSeg2        = 0x2U;
        bitTimes.nomSynchJumpWidth  = 0x1U;
        bitTimes.dataRatePrescalar  = 0x1U;
        bitTimes.dataTimeSeg1       = 0x3U;
        bitTimes.dataTimeSeg2       = 0x2U;
        bitTimes.dataSynchJumpWidth = 0x1U;

    You are using again same values in FAQ for 1 Mbps and 5 Mbps . But weren't you going with 500Kbps and 2 Mbps on the other end ?

    You need to configure both ends of CAN with same Nominal and bit rates, which you are not doing now currently.

    Regards

    Tarun Mukesh

  • Hi Tarun,

    This is not the bps rate issue. The reason That I need to change is thar your default application bit timeing can not applied to PCAN Viewer, So after I change both of the norminal and data SynchJumpWidth to value 1U , that I can apply to PCAN Viewer. 

    From PCAN Viewer records, why the message id "004h " not match application "Message ID: 0x100000" setting ?

  • Hello,

    This is not the bps rate issue. The reason That I need to change is thar your default application bit timeing can not applied to PCAN Viewer, So after I change both of the norminal and data SynchJumpWidth to value 1U , that I can apply to PCAN Viewer. 

    ok understood.

    The tx message id is 0x4 only in the source code, the msg id for standard bit frame cannot be more than 11 bit. whatever you are receiving on PCAN is correct only.

    /* Initialize Tx Buffer Config params */
    stdFiltelem.sfid2 = 0x0U;
    stdFiltelem.sfid1 = 0x4U;
    while they used as below so it is showing your "Message ID: 0x100000" 
     
    Regards
    Tarun Mukesh
  • Hi Tarun,

    txMsg.id  = (uint32_t)((uint32_t)(0x4U) << 18U);

    1) question about CAN message id assignment 

    As you mention standard bit frame cannot be more than 11 bit.

    0x4U in binary is : 

    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0000 0100

    0x100000 in binary:

    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0001 0000
    0000 0000 0000 0000

    Why it just shift 18 bits long ?

    2)  How to receive any kind of CAN message ID ?

    Modify  txMsg.id  = (uint32_t)((uint32_t)(0x3A9U) << 18U);  Expected the application can receive can message id : 0x3A9. 

    Perform 4. Loopback - external transmission and reception

    The application is stop like below

    The receive only receive one message and then stop .

    Is ther are any filter only can receive the CAN message ID "txMsg.id  = (uint32_t)((uint32_t)(0x4U) << 18U); " ?

  • Hello,

    1)

    question about CAN message id assignment 

    As you mention standard bit frame cannot be more than 11 bit.

    0x4U in binary is : 

    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0000 0100

    0x100000 in binary:

    0000 0000 0000 0000
    0000 0000 0000 0000
    0000 0000 0001 0000
    0000 0000 0000 0000

    Why it just shift 18 bits long ?

    Standard Identifier in hardware starts from id[28:18] so we need to shift the standard identifier with 18.

    2)

    How to receive any kind of CAN message ID ?

    Modify  txMsg.id  = (uint32_t)((uint32_t)(0x3A9U) << 18U);  Expected the application can receive can message id : 0x3A9. 

    Yes the expected message id should be of 0x3A9 but it has to pass through the filters. You need to take care of sfid1,sfid2,sfec,sft values for 0x3A9 to receive.

    In case of above default example we have filter values as below,

        /* Initialize Tx Buffer Config params */
        stdFiltelem.sfid2 = 0x0U;
        stdFiltelem.sfid1 = 0x4U;
        stdFiltelem.sfec  = 0x7U;
        stdFiltelem.sft   = 0x0U;

    Regards

    Tarun Mukesh

  • Hi Tarun,

    How to disable the stdFiltelem filter or config to receive any kind of CAN message ?

  • Hello ,

    You can look into Registers of J721S2 for standard filter elements or look into CAN protocol documents to configure to receive any kind of CAN messages.

     https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/7.40.00.64/exports/docs/drivers/doxygen/html/struct_m_c_a_n___std_msg_i_d_filter_element.html

    Regards

    Tarun Mukesh

  • Hi Tarun,

    Where is the CAN protocol documents ?

  • Hello,

    CAN protocol documents i cannot share it will be with BOSCH.You can refer in TRM/Regsiters of J721S2 to understand the configuration of standard filter elements.

    Regards

    Tarun Mukesh