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.

CAN mailbox problem TMS320F28335

Other Parts Discussed in Thread: TMS320F28335

Dear all,

I've got a problem with mailboxes while using the eCANA peripheral of the TMS320F28335. I've configured mailbox 0 to 7 for reception and 8 to 12 for transmission. In this way the program works well but if I try to configure in addition one of the mailboxes between 16 and 31 for transmission, my application only sends the message that has the mailbox between the 16 and 31.

My first guess was that it could be a problem with the CAN mode but I've checked it and the register is (CANMC.13 = 1).

Does anyone have an idea of what else could it be?

Thanks in advance,

Aitor

  • Hi Aitor,

    Check how you are sending the messages. Are you sending them by wrtiting a 1 to CANTRS register? Couple of  other things you can check:

    1. Use CANshadow registers as mentioned in the peripheral guide.

    2. Ensure that the different mailboxes are not configured to send the message with same message ID.  It can cause the CAN bus to collapse and transmit only one of the messages.

    Regards,

    Vivek

  • I have a similar problem with the TMS320F28335.

    Only one CAN message is being sent. 

    - I'm using shadow registers.

    - I do not configure different mailboxes with same msg id.

    - I do not write the msg id to an enabled msg box, but disable first.

    This is my can_send() for testing:

    int can1_send (canmsg_t* pmsg)
    {
    int retval = 0;

    /* disable mailbox before writing to it */

    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME25 = 0;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;

    /* Write to the MSGID field */

    ECanaMboxes.MBOX25.MSGID.all = 0x12345 | 0x80000000;

    /* Write to DLC field in Master Control reg */

    ECanaMboxes.MBOX25.MSGCTRL.bit.DLC = 8;

    /* Write to the mailbox RAM field */
    ECanaMboxes.MBOX25.MDL.all = 0x01;
    ECanaMboxes.MBOX25.MDH.all = 0x55555555;

    /* Configure Mailbox under test as a Transmit mailbox */

    ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
    ECanaShadow.CANMD.bit.MD25 = 0;
    ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;

    /* Enable Mailbox under test */
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME25 = 1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;

    ECanaShadow.CANTRS.all = 0;
    ECanaShadow.CANTRS.bit.TRS25 = 1; // Set TRS for mailbox under test
    ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;

    do
    {
        ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
    } while (ECanaShadow.CANTA.bit.TA25 == 0); // Wait for TA25 bit to be set..

    ECanaShadow.CANTA.all = 0;
    ECanaShadow.CANTA.bit.TA25 = 1; // Clear TA5
    ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;

    ECanaRegs.CANTRS.all = 0;

    return retval;

    }

    What's wrong here?

    Regards,

    Michael

  • Aitor,

                Things to double check for the problematic mailbox(es) in question: (it is better to check these values directly in the Memory window for the CAN Control registers space)

     

    Is the value of CANME correct? (=1?)

    Is the value of CANMD correct? (=0?)

    Is the value of CANMC.SCB correct? (=1?)

    Are you able to see the MSGID and data correctly written into the mailbox-RAM?

    Are you able to see the TRS bit being set? Have you tried reading back the bit?

    Do you employ 32-bit writes, as explained in the user guide? This is VERY important.

     

    Also, when you said "my application only sends the message that has the mailbox between the 16 and 31" , did you mean to say "mailbox between 8 and 12" ?

  • Vivek,

                In your post, I presume you meant to say "Ensure that the different mailboxes nodes are not configured to send a message with same message ID.  It can cause the CAN bus to collapse and transmit only one of the messages".

  • Michael,

                You mention "Only one CAN message is being sent", so I take it that there is at least one other node on the bus to ACK the transmitted frame and that there are no hardware issues. I do not see anything wrong with your code. Are you saying no more frames are transmitted from MBOX25 or are you saying no frames are transmitted from any MBX in this node?

  • Hareesh and team,

    I'm quite embarrassed... in fact it was my fault, that only one CAN message was sent.

    At the beginning, I made the mistake of changing the mailbox RAM, while it was enabled. In the example code, I started with, the ID and data was set once before enabling and never changed...  It was not obvious, that you are not allowed to do this. This resulted in some weird behaviour and hanging of the CAN module...

    After realizing this, I changed it and fixed everything according to your suggestions. Stupidly I merged some stuff of my application at the same time. As an experienced engineer you should not do this (murphys law is merciless)...

    So, I'm sorry for bothering you with my issues. You guys have really great products and superior support!

    Regards, Michael. 

  • Michael,
    Good to know your problem got resolved. Please do not be harsh on yourselves. I have made similar mistakes myself.