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.

TMS320F28388D :CM_MCAN (Classic CAN Mode Operation) ID Read Data Value incorrect

Part Number: TMS320F28388D

Currently, MCAN is used as classic CAN, and transmit is completed and RECEIVE is also performed, but the ID value is a little strange.

RECEIVE with ID = 0x300, MCAN_readMsgRam(MCAN0_BASE, MCAN_MEM_TYPE_FIFO, 0U, MCAN_RX_FIFO_NUM_1, &rxMsg1);
Looking at the ID part of the rxMsg1 buffer, it is received as 0x0C000600.
If ID = 0x300, it should be 0x0C000000, but I am wondering why there is 0x00000600 after this part.

Why is this?

  • Below is the MCAN Config setting.

    static void MCANConfig(void)
    {
    uint32_t fdoe;
    MCAN_RevisionId revId;
    MCAN_InitParams initParams;
    MCAN_ConfigParams configParams;
    MCAN_MsgRAMConfigParams msgRAMConfigParams;
    MCAN_StdMsgIDFilterElement stdFiltelem;
    MCAN_ExtMsgIDFilterElement extFiltelem;
    MCAN_BitTimingParams bitTimes;

    //
    // Initialize MCAN Init parameters.
    //
    initParams.fdMode = 0x0U; // FD operation disabled.
    initParams.brsEnable = 0x0U; // Bit rate switching for
    // transmissions enabled.
    initParams.txpEnable = 0x1U; // Transmit pause enabled.
    initParams.efbi = 0x0U; // Edge filtering disabled.
    initParams.pxhddisable = 0x0U; // Protocol exception handling enabled.
    initParams.darEnable = 0x1U; // Automatic retransmission of messages
    // not transmitted successfully enabled.
    initParams.wkupReqEnable = 0x1U; // Wakeup request is enabled.
    initParams.autoWkupEnable = 0x1U; // Auto-Wakeup is enabled.
    initParams.emulationEnable = 0x1U; // Emulation/Debug Suspend is enabled.
    initParams.tdcEnable = 0x1U; // Transmitter Delay Compensation is
    // enabled.
    initParams.wdcPreload = 0xFFU; // Start value of the Message RAM
    // Watchdog Counter preload.
    //
    // Transmitter Delay Compensation parameters.
    //
    initParams.tdcConfig.tdcf = 0xAU;
    initParams.tdcConfig.tdco = 0x6U;

    //
    // Initialize MCAN Config parameters.
    //
    configParams.monEnable = 0x0U; // Bus Monitoring Mode is disabled.
    configParams.asmEnable = 0x0U; // Normal CAN operation.
    configParams.tsPrescalar = 0x2U; // Prescaler Value.
    configParams.tsSelect = 0x2U; // Timestamp counter value.
    configParams.timeoutSelect = MCAN_TIMEOUT_SELECT_CONT;
    // Time-out counter source select.
    configParams.timeoutPreload = 0xFFFFU;// Start value of the Timeout
    // Counter.
    configParams.timeoutCntEnable = 0x0U; // Time-out Counter is disabled.
    configParams.filterConfig.rrfs = 0x1U; // Reject all remote frames with
    // 29-bit extended IDs.
    configParams.filterConfig.rrfe = 0x1U; // Reject all remote frames with
    // 11-bit standard IDs.
    configParams.filterConfig.anfe = 0x1U; // Accept in Rx FIFO 1.
    configParams.filterConfig.anfs = 0x1U; // Accept in Rx FIFO 1.

    //
    // Initialize Message RAM Sections Configuration Parameters
    //
    msgRAMConfigParams.flssa = MCAN_STD_ID_FILT_START_ADDR;
    // Standard ID Filter List Start Address.
    msgRAMConfigParams.lss = MCAN_STD_ID_FILTER_NUM;
    // List Size: Standard ID.
    msgRAMConfigParams.flesa = MCAN_EXT_ID_FILT_START_ADDR;
    // Extended ID Filter List Start Address.
    msgRAMConfigParams.lse = MCAN_EXT_ID_FILTER_NUM;
    // List Size: Extended ID.
    msgRAMConfigParams.txStartAddr = MCAN_TX_BUFF_START_ADDR;
    // Tx Buffers Start Address.
    msgRAMConfigParams.txBufNum = MCAN_TX_BUFF_SIZE;
    // Number of Dedicated Transmit Buffers.
    msgRAMConfigParams.txFIFOSize = MCAN_TX_FIFO_SIZE;
    // Tx FIFO/Queue.
    msgRAMConfigParams.txBufMode = 0U;
    // msgRAMConfigParams.txBufElemSize = MCAN_ELEM_SIZE_64BYTES;
    msgRAMConfigParams.txBufElemSize = MCAN_ELEM_SIZE_8BYTES;
    // Tx Buffer Element Size.
    msgRAMConfigParams.txEventFIFOStartAddr = MCAN_TX_EVENT_START_ADDR;
    // Tx Event FIFO Start Address.
    msgRAMConfigParams.txEventFIFOSize = MCAN_TX_BUFF_SIZE;
    // Event FIFO Size.
    msgRAMConfigParams.txEventFIFOWaterMark = MCAN_TX_EVENT_WATERMARK;
    // Level for Tx Event FIFO watermark interrupt.
    msgRAMConfigParams.rxFIFO0startAddr = MCAN_FIFO_0_START_ADDR;
    // Rx FIFO0 Start Address.
    msgRAMConfigParams.rxFIFO0size = MCAN_FIFO_0_NUM;
    // Number of Rx FIFO elements.
    msgRAMConfigParams.rxFIFO0waterMark = MCAN_FIFO_0_WATERMARK;
    msgRAMConfigParams.rxFIFO0OpMode = 0U;
    msgRAMConfigParams.rxFIFO1startAddr = MCAN_FIFO_1_START_ADDR;
    // Rx FIFO1 Start Address.
    msgRAMConfigParams.rxFIFO1size = MCAN_FIFO_1_NUM;
    // Number of Rx FIFO elements.
    msgRAMConfigParams.rxFIFO1waterMark = MCAN_FIFO_1_WATERMARK;
    // Level for Rx FIFO 1 watermark interrupt.
    msgRAMConfigParams.rxFIFO1OpMode = 0U; // FIFO blocking mode.
    msgRAMConfigParams.rxBufStartAddr = MCAN_RX_BUFF_START_ADDR;
    // Rx Buffer Start Address.

    // msgRAMConfigParams.rxBufElemSize = MCAN_ELEM_SIZE_64BYTES;
    // // Rx Buffer Element Size.
    // msgRAMConfigParams.rxFIFO0ElemSize = MCAN_ELEM_SIZE_64BYTES;
    // // Rx FIFO0 Element Size.
    // msgRAMConfigParams.rxFIFO1ElemSize = MCAN_ELEM_SIZE_64BYTES;
    // // Rx FIFO1 Element Size.

    msgRAMConfigParams.rxBufElemSize = MCAN_ELEM_SIZE_8BYTES;
    // Rx Buffer Element Size.
    msgRAMConfigParams.rxFIFO0ElemSize = MCAN_ELEM_SIZE_8BYTES;
    // Rx FIFO0 Element Size.
    msgRAMConfigParams.rxFIFO1ElemSize = MCAN_ELEM_SIZE_8BYTES;
    // Rx FIFO1 Element Size.

    //
    // Initialize Tx Buffer Configuration parameters.
    //
    stdFiltelem.sfid2 = 0x7FFU; // Standard Filter ID 2.
    stdFiltelem.sfid1 = 0x0U; // Standard Filter ID 1.
    stdFiltelem.sfec = 0x7U; // Store into Rx Buffer or as
    // debug message, configuration of SFT[1:0] ignored.
    stdFiltelem.sft = 0x0U; // Range filter from SFID1 to SFID2.

    // //
    // // Initialize Tx Buffer Configuration parameters.
    // //
    // extFiltelem.efid2 = (0x9U << 4U);
    // extFiltelem.efid2 |= 0xFU;
    // extFiltelem.efid1 = (0x0U << 4U);
    // extFiltelem.efid1 |= 0xFU;
    // extFiltelem.efec = 0x6U;
    // extFiltelem.eft = 0x0U;

    //
    // Initialize bit timings.
    //
    bitTimes.nomRatePrescalar = 0x9U; // Nominal Baud Rate Pre-scaler.
    bitTimes.nomTimeSeg1 = 0x1U; // Nominal Time segment before sample point.
    bitTimes.nomTimeSeg2 = 0x1U; // Nominal Time segment after sample point.
    bitTimes.nomSynchJumpWidth = 0x0U; // Nominal (Re)Synchronization Jump Width Range.
    // bitTimes.dataRatePrescalar = 0x3U; // Data Baud Rate Pre-scaler.
    // bitTimes.dataTimeSeg1 = 0x0U; // Data Time segment before sample point.
    // bitTimes.dataTimeSeg2 = 0x0U; // Data Time segment after sample point.
    // bitTimes.dataSynchJumpWidth = 0x0U; // Data (Re)Synchronization Jump Width.

  • Hi Gyou,

    The txmsg and rxmsg are un initialized buffers so they may have existing values in the memory. Based on the message if its a standard frame use the ID value right shifted by 18 or if its an extended frame use the complete ID.

    Regards,

    Yashwant