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.

TMS320F28335: CAN Transmit mailbox priority not worked as user guide's description

Part Number: TMS320F28335


Hi Team,

  My customer reported an issue for TMS320F28335 CAN transmit mailbox priority not worked as user guide description:

  Mailbox 14 and mailbox 12 were set to transmit mailbox, while TRS of the mailbox 12 and mailbox are both set,  the mailbox 12 with low priority will send out firstly and the send the higher priority mailbox14.

 Could you kindly give comments on below questions: 

1) What's CPK and Message controller work flow? And if lower priority mailbox is fulfilled with data(TRS is set to 1, and but not send out, meanwhile the higher priority mailbox is fulfilled with data(TRS is set to 1), as lower priority mailbox hasn’t send out, would be the transmit buffer reversed by higher priority mailbox and transmit context at the mailbox with higher priority firstly?  

2) Why the low priority mailbox send firstly if another higher priority mailbox(TRS) is set?

the detailed info can be found in attached file.

 

Best Regards

Benjamintms320F28335 eCAN priority transmit issue.docx

  • Hi Team,
    In the user guide, it mentioned: “Message controller is also responsible for sending the next message to transmit to the CPK according to the message’s priority”, does is mean that: if the Transmit buffer are filled with context of low priority mailbox, the Transmit buffer will still send out the context with low priority, and for next transmit buffer, it will filled with higher priority mailbox context?
    Expect for your reply, thanks.

    Best Regards
    Benjamin
  • Benjamin,

                You are correct that once the transmit buffer is filled with a message, it will go out first. Transmit priority works the way it is explained in the User guide when the TRS bits of the mailboxes in question are set at the same time. Let me know if this answers your question.

  • Hi Hareesh,
    These is a description in user guide chapter 1.5.1 shown as below: "If a transmission fails due to a loss of arbitration or an error, the message transmission will be reattempted. Before reattempting the transmission, the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority."
    Also as mentioned for customer reported issues in the first post , the Node 2 TRS.12 and TRS.14 are both set 1, and also there are other higher priority ID frames are in the bus, according to the chapter 1.5.1, which Node 2 CAN controller should transmit the mailbox 14 firstly and then transmit mailbox12 later.
    What's your comments for the customer issues? Based on chapter 1.5.1, it seems that mailbox 14 should be transmitted firstly, but based on chapter 1.2.1 and previous post, it's normal that mailbox 12 transmit firstly. it's confused.
    What's your suggestion for how to realize the feature: Higher priority CAN mailbox send firstly, lower priority later? As this reported priority issue, based on the test, as the higher priority mailbox can't be transmitted, some system higher timing operation based on the CAN data would miss the timing limitation, which decreased the system performance.
    Expect for your reply, thanks.

    PS:
    Node 1
    Frame 1 ID:1 1100 1000 1000 xxxx xxxx xxxx xxxx
    Frame 2 ID:1 1100 1100 1000 xxxx xxxx xxxx xxxx
    Frame 3 ID:1 1101 0000 1000 xxxx xxxx xxxx xxxx
    Node 2:
    Frame 4 ID:1 1100 1001 0000 xxxx xxxx xxxx xxxx
    Frame 5 ID:1 1101 0001 0000 xxxx xxxx xxxx xxxx


    Best Regards
    Benjamin
  • Hi Hareesh:
    Also could you kindly reply the questions in the first post?
    1) What's CPK and Message controller work flow? And if lower priority mailbox is fulfilled with data(TRS is set to 1, and but not send out, meanwhile the higher priority mailbox is fulfilled with data(TRS is set to 1), as lower priority mailbox hasn’t send out, would be the transmit buffer reversed by higher priority mailbox and transmit context at the mailbox with higher priority firstly?

    2) Why the low priority mailbox send firstly if another higher priority mailbox(TRS) is set?

    Expect for your reply, thanks.

    Best Regards
    Benjamin
  • In 1.5.1 of SPRUEU1, TMS320F2833x, 2823xEnhanced Controller Area Network (eCAN) Reference Guide, it mentioned : "If a transmission fails due to a loss of arbitration or an error, the message transmission will be reattempted. Before reattempting the transmission, the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority. "
    The priority logic is right, but this contradicts the logic that Benjamin mentions.
  • Benjamin,

                As explained in my first post, once the transmit buffer is filled with a message , it would go out even if transmission of other higher priority messages were subsequently initiated. Pay attention to the word "subsequently".

     

    User5049454,

                "If a transmission fails due to a loss of arbitration or an error, the message transmission will be reattempted. Before reattempting the transmission, the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority. "

     

    Consider a scenario where there is neither loss of arbitration nor an error, but a mailbox is marked for transmission when normal CAN communication is going on. When TRS is set to 1, the message is copied to the transmit buffer.

  • I know the normal condition, but I need to know the condition of a loss of arbitration or an error. For example, consider the following timing:
    1). Node A's low-priority mailbox first requests to send data, but now the BUS is busy, the data from the low-priority mailbox will be sent when the BUS is free;
    2). Node A's high-priority mailbox also requests to send data before the bus is free;
    3). Now the BUS is free, but the data from node A's low-priority mailbox try to be sent but can't be sent to the BUS successfully due to a loss of arbitration(other nodes arbitrate the BUS successfully due to the high-priority frame ID) ;
    4).When the BUS is free again, which mailbox's data from Node A will be sent to the BUS?The low-priority 's or the high-priority's?
  • For the scenario you described, the high-priority message should be transmitted, as per the spec.
  • Hareesh,
    How to identify the scenario descripted with 4 steps in upper post? Is there any CAN status bit can reflex these scenario?

    Best Regards
    Benjamin
  • Hi Hareesh

           I very much agree with your point of view and I also think that the message from the high-priority mailbox will be sent first.

          This logic is really worthwhile, Otherwise, message of the low-priority mailbox is occupying the TX buffer for a long time due to a loss of arbitration, and the message of the high-priority mailbox can not be sent.

          In fact, this scene will often happen. For example, a system is designed such that some low-priority messages need to be periodically transmitted on the CAN bus, and some high-priority messages need to be sent at random and require a low latency response.

         TMS320F28335 CAN peripherals Most scenes are that high-priority messages is sent first, but we find that sometimes very low probability is low-priority messages is sent first.

        Our system CAN bus occupancy rate of about 75%, and CAN baud rate is 500Kbps, and a frame of data transmission time is about 300us.The following timing occurs:

        1).  A message from low-priority mailbox first requests to send, but now the BUS is busy, the message is not sent successfully;

        2).  About after 1milliseconds, a high-priority mailbox message is also requested to send, then low-priority mailbox data is still not yet sent successfully.

        3). After another 2 milliseconds, the low-priority mailbox data is sent successfully but the  high-priority mailbox message is still not yet sent successfully until low-priority mailbox message is sent successfully.

        Please tell me what happened.I will wait for your reply online.

        Thanks.

       

  • Benjamin Zhou said:
    Hareesh,
    How to identify the scenario descripted with 4 steps in upper post? Is there any CAN status bit can reflex these scenario?

    Best Regards
    Benjamin

    No, there is no status bit that reflects this scenario.

    1. You set TRS for low-priority MBX. Data is transferred to the TX buffer, but is not sent out (because bus is busy).
    2. You set TRS for high-priority mailbox.
    3. Meanwhile, when the bus becomes free, low-priority mailbox's data is attempted to be transmitted, but arbitration lost.
    4. Now, when the bus becomes free and re-transmission of the low-priority mailbox is attempted, the CAN module is supposed to check for any pending high-priority mailbox waiting to be transmitted. (It is conceivable that the CAN module checks for any high-priority mailbox waiting to transmit upon loss of arbitration itself).
    5. Now, sometimes, a low-priority mailbox is transmitted instead.

     

    Now, how did you ascertain that there was indeed a loss of arbitration? That would be very hard to prove, since once we set the TRS bit, the precise moment at which a frame goes out is no more under our control. It could be that the TRS bit of the low-priority mailbox was set before the high-priority mailbox and there was no error or loss of arbitration. I can think of one way to experimentally verify this:

    Let us assume MBX0 has the low-priority message and MBX1 has the high-priority message.

    Toggle GPIOx when TRS0 is set. Toggle GPIOy when TRS1 is set. Trigger the scope on GPIOy. Capture the CAN traffic in another channel. Normally, GPIOy should toggle first followed by GPIOx. If the opposite happens, look thru the CAN traffic to see if there was indeed a loss of arbitration. You probably may want to use a low-cost USB-based logic analyzer instead of a scope. It is a little tricky to get the triggers right, but we need to convince ourselves that there indeed was a loss of arbitration and the CAN module still sent the low-priority message out, even though a high-priority message was waiting.

     

  • Please take a look at this post:https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/343127/1626209#1626209  It appears you are facing a similar situation. Following is the design analysis:

     

    Right now, our User Guide says this:

    If a transmission fails due to a loss of arbitration or an error, the message transmission will be re-attempted. Before reattempting the transmission, the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority.

     

    A better and more precise wording would be as follows:

    If a transmission fails due to a loss of arbitration or an error, the message transmission will be re-attempted. Before re-attempting the transmission, the CAN module checks if other transmissions are requested. If the TRS bit of a higher-priority (determined either by the MBX number or by the associated TPL value) mailbox had been set before the message in the transmit-buffer has lost arbitration, the transmit-buffer contents will be replaced with that of the higher-priority mailbox and the higher priority mailbox will be transmitted after the arbitration loss. However, if that TRS bit was set after the message in the transmit-buffer has lost arbitration, the higher priority MBX will be transmitted only after the current message in transmit-buffer has transmitted.

  • I would also like to bring your attention to a suggestion provided by Mr.Frank Bormann in the other thread:

     

    "...Did you consider using the TRR-Register? Would that help? In my understanding a TRR=1 would cancel a transmission request, which is already in progress but due to a lost in arbitration not successful (see UG chapter 2.4). So if your node needs to transmit an urgent message, it could check if other TRS bits are still set and cancel these requests by setting the TRR bits......."

  • There are two ways to know if an arbitration is lost:

    1. We can calculate whether the arbitration is lost. At 500Kbps baud rate, a frame transmission time is roughly 300 microseconds. Rarely,

        Step1: We set TRS for low-priority MBX firstly. Data from the low-priority MBX is transferred to the TX buffer Immediately.

        Step2: After 1 milliseconds, We set TRS for high-priority MBX, Meanwhile, low-priority mailbox's data is not sent out.

        Step3: After another 2 milliseconds, low-priority mailbox's data is sent out successfully, Meanwhile the high-priority mailbox's data is not sent out.

        Within 2 milliseconds from Step2 to Step3, About 6 frames data can be transmitted through CAN-BUS. If low-priority mailbox's data is attempted to be transmitted continuously within 2 milliseconds, it will certainly result in the loss of arbitration. If the high-priority mailbox's data is attempted to be transmitted, the high-priority mailbox's data is sent out successfully prior to the low-priority mailbox.

    2. Another intuitive way, we use the oscilloscope to detect TX and RX.

        The frame ID for the high-priority and low-priority mailboxes is different, In the CAN-BUS competition, we are very intuitive to find low-priority mailbox data has been arbitration failure many times, but TRS for high-priority mailbox is set.

       The above two methods are confirmed in the laboratory several times. The conclusion is that in rare cases, low-priority mailbox data is sent out prior to high-priority mailbox data.

  • 1. Between step 1 and step 2, there is 1 mS. Only in step 2 is the TRS for the high-priority mailbox set. This means the bus is hosting high-priority messages between step 1 & step 2 and the low-priority message has lost arbitration. And TRS for the high-priority message is set after the message in the transmit-buffer has lost arbitration. So, per my previous message the low-priority message goes out first.

     

    2. I am afraid I don’t understand what you are describing here. In any case, what is important is the relative offset in time of when TRS for the high-priority MBX is set with respect to when arbitration loss happens.

     

     

  • 1. TRS for the high-priority message is set after the message in the transmit-buffer has lost arbitration, But after 2 milliseconds, the data for the low priority mailbox is sent out. In 2 millisecondse, low-priority mailbox message has lost arbitration about 6 times. Why high-priority mailbox message can not be loaded the transmit-buffer. Could it be said that the logic that "the low-priority mailbox message arbitration failure, and the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority" is right only for the first time not every time?

    2. I would like to say we can  to intuitively judge whether or not to lost arbitration through TX and RX.

  • Could it be said that the logic that "the low-priority mailbox message arbitration failure, and the CAN module checks if other transmissions are requested and then transmits the mailbox with the highest priority" is right only for the first time not every time?

    Answer--> It certainly appears to be the case..