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.

AM3359: DCAN message object configuration in RTOS

Part Number: AM3359

Hello,

I am developing the CAN node on AM3359 Sitara ICEv2 board. I have merged the starterware DCAN Rx Tx example with the SYS/BIOS and the example works properly to send the CAN messages.

The CAN reception also works fine but I can receive only 3 CAN messages after that the CAN messages are not getting received. This I suppose because I configured 3 message objects. I want to understand how the CAN communication works in AM335x.

I referred the TRM of AM335x but it is still not clear for me. Can someone share a good document to explain what all things need to be configured for CAN communication and how these message objects are used?

From my understanding, we need to do the following:

1. Place DCAN in Initialization mode

2. Set the bit time

3. Configure the message object

4. Place DCAN in Normal mode.

Now my question is once the message object is configured to receive the message and the ISR is called in normal mode to indicate message is received then do we invalidate that particular message object in ISR? If the message object is invalidated then will it receive the next CAN message? Do we have to configure everytime for a new CAN message to receive?  

For every CAN write/Tx, do we have to configure the message object?

Working with the version: processor_sdk_rtos_am335x_4_00_00_04 and pdk_am335x_1_0_7

regards

Mohit

  • The RTOS team have been notified. They will respond here.
  • Hi Lali,

    No, I have already seen this link. It explains about different APIs and what these APIs do. But I am more interested in understanding what shall be the order of using these APIs.

    Basically I want more details about message objects. I am bit confused on the requirement of making the message object valid or invalid and what happens when we have messages coming continuously, then how shall these message objects shall be handled?

    regards

    Mohit

  • Hi Mohit,

    The MsgVal bit indicates to the CAN IP if the message object can be used or not. The driver developer has the option to enable a few or all of the messages in the CAN message RAM. I can't explain why a developer might want to do that but that is the purpose of that bit.

    At the moment I am not sure how to answer the streaming question. The use case desribed above are you reading the RX message RAM? The TRM shows this clears the new data flag in the RX message RAM. Could you describe the message sequence that you are doing?

    Regards,
    Schuyler
  • Hello Schuyler,
    So what I understand is if a developer wants to use 5 message objects then he/she will set the msg Val bit of these message objects. The NexDataX flag shall be used for reading the message object in polling mode.
    But in interrupt mode, the IntPnd flag shall be used for reading a message object. When a message is received at the CAN core, it is transferred to configured message object. The IntPnd flag is also set when a message is received. The ISR is called and in ISR the message object is read and copied to application.
    Now when a message is read by application, then what shall the application do to the message object after copying the CAN frame. Do we need to set some register? Do we need to clear some bits?

    Here is a snippet of DcanAppIsr for receive
    /* Interrupt handling for receive message objects. */
    if((msgObjNum >= (instObj->maxMsgObjs/2U)) &&
    (msgObjNum < instObj->maxMsgObjs))
    {
    /* Read a received message from message RAM to interface register */
    DCANAppReadMsgObjData(instObj->instAddr,
    msgObjNum,
    (uint32_t*) rxData,
    DCAN_IF_REG_NUM_2);

    /* Clear the Interrupt pending status */
    DCANAppIntrClear(instObj->instAddr,
    msgObjNum,
    DCAN_IF_REG_NUM_2);

    pDataVal = (uint8_t*) rxData;

    instObj->appIntrCfg.frameLen = (DCANIfMsgCtlStatus(instObj->instAddr, DCAN_IF_REG_NUM_2) &
    DCAN_MSG_CTL_STS_DAT_LEN_CODE);

    //copy data to application
    recvdFrame.dcanId = (DCANIfArbitrationStatus(instObj->instAddr, DCAN_IF_REG_NUM_2) & DCAN_ARB_STS_MSG_ID) >> 18;
    recvdFrame.dcanLen = instObj->appIntrCfg.frameLen;
    recvdFrame.dcanData[0] = rxData[0];
    recvdFrame.dcanData[1] = rxData[1];
    ECAT_DataReceivedOnCAN(&recvdFrame); //will not do any processing in ISR; just copy to application
    //End copying data

    if(instObj->appIntrCfg.totalFrames == instObj->appIntrCfg.intrCount)
    {
    /* Disable the receive interrupt of the message object */
    DCANAppRxIntrDisable(instObj->instAddr,
    msgObjNum,
    DCAN_IF_REG_NUM_2);

    /* Invalidate the receive message object */
    DCANAppInvalidateMsgObject(instObj->instAddr,
    msgObjNum,
    DCAN_IF_REG_NUM_2);
    }



    My testing sequence :
    AM3359 is connected to CANalyzer. The CANalyzer is generating the CAN messages continuously and periodically. These CAN messages shall be received by DCAN and it shall be transferred to application. The messages generated have different CAN Ids, so I do not configure the message object to a single CAN id. But I have configured the message object to CAN id 0 to receive all CAN messages.

    regards
    Mohit
  • Hi Mohit,

    Looking through this section 23.3.14 Configuration of Message Objects talks about reading message objects and resetting the NewDAT and IntPend bits. The IF command register indicates the bits can cleared on reading the object. This section talks about enabling all the message objects. Are you not receiving anymore after the 5 configured message objects are received?

    I looked through the Linux driver and I don't see the bits being cleared on reading the object, a comment says these bits are self clearing. The Linux driver also uses polling to process RX objects.

    Best regards,
    Schuyler
  • Hello Schuyler,
    I configured only one message object for reception to test and it is self clearing. So I am able to receive the messages continuously. But what will happen if I configure more than 1 message object and all with the CAN id of 0 (to recv all frames). So which message object will recv the actual frame. Will it go to next available message object or does it go to all the message objects?

    One more question regarding configuring a message object for Tx. I see that in the loopback example the message object is configured in ISR call everytime a message is recvd. Can we not configure the message object at the beginning for Tx and update the message in ISR? Do we have to configure the message object in runtime for CAN Transmit?

    regards
    Mohit
  • Hello Mohit,

    Section 23.3.15.2 Receive/Transmit Priority of the TRM is describing that the message object number (not the can id) controls the receive priority. So, based on that it looks like the next received message should go to the next ascending message object of the ones that are configured.

    For the transmit question, if I understand correctly you want to start a transfer and then update via the ISR, this section I believe describes that 23.3.15.4 Updating a Transmit Object. In fact it discusses that the update can happen even if the message is transit so your design of updating should work in the driver you are writing.

    Best Regards,
    Schuyler