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.

TMS320F2800137: TMS320F2800137 CAN Bus back to back transfer

Part Number: TMS320F2800137

Hi,

Is there a way to detect if the CANBus transmit FIFO is not full in this case I can send a new packet immediately if not full? 

Thanks,

Arnaud

  • Arnaud,

        Can you please explain further what exactly is your objective? FIFO is suitable for receive operation. 

  • Hi,

    What is the best way to check if I can send a new TX frame?

    Is TxOk bit the only indication? Is their another bit or other way?. TxOk will not be set if I did not send any frame first. 

    I will prefer if there is something that indicate that the CAN peripheral is ready to send a frame.

    Thanks,


    Arnaud

  • What is the best way to check if I can send a new TX frame?

    You can always mark any number of message objects for transmission by setting the TXRQST bit in the CAN_IF1CMD Register. Messages will be transmitted based on different conditions:

    1. Whether the bus is free
    2. If the bus is free, message objects will be transmitted based on the internal priority in the DCAN module.
    3. If there is a contention with another node in the network, that contention will be resolved based on the ARBID (MSGID) of the frames competing for the bus.
    Is TxOk bit the only indication?

    TxOK bit tells you whether the last transmitted frame was correctly transmitted on the bus (and was ACKnowleged by at least one other node on the network). This bit is useful if you want to poll for the completion of transmission. Applications typically use interrupts (not polling).

    Is their another bit or other way?.

    If your objective is to check whether there are any pending transmissions (i.e. whether previously initiated transmissions have completed successfully), you can always poll the CAN_TXRQ_21 Register.

    TxOk will not be set if I did not send any frame first. 

    Correct,

    I will prefer if there is something that indicate that the CAN peripheral is ready to send a frame.

    As mentioned before, you can queue messages for transmission, as long as the message object you are going to use is currently empty.

  • Hi, You said "you can queue messages for transmission, as long as the message object you are going to use is currently empty."

    How do you check that the queue msg is empty? Is it by checking CAN_TXRQ_21?

    If it is, I do that but it seems that some TX frame are missing or bypass when I check the bus using a scope even if I send them.

    See busy code detection below.

    Thanks,

    Arnaud

    // 0: ok, ready to transmit
    // 1: busy, need to wait
    int32_t IS_CAN_TX_BUSY(uint32_t objID)
    {
    if((HWREG_BP(CAN_MODULE + CAN_O_TXRQ_21) & (1u<<objID)) == 0)
    {
    canbus_not_busy++;
    return 0;
    }
    else
    {
    canbus_busy++;
    return 1;
    }
    }

  • How do you check that the queue msg is empty? Is it by checking CAN_TXRQ_21?

    You can only check if the message object you intend to use for transmission is ready to accept the next message. Yes, you can do this by checking the CAN_TXRQ_21 register.

    some TX frame are missing or bypass when I check the bus using a scope even if I send them.

    This is a very difficult question to answer. I presume you are checking the TxRqst bit for a Message Object and initiate a transmission when the bit corresponding to that Message Object is 0 (meaning there are no pending transmissions from that object).  If you are solely relying on a scope, sometimes, it is easy to miss a frame if the scope is not setup to trigger correctly. Please use a bus analyzer to monitor the bus, if you are not using one already.

    You can eliminate this issue by using interrupts. An interrupt would be asserted when the object has completed transmission. 

  • Arnaud,

        To clarify, the concept of FIFO is only applicable for receive message objects.