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.

TMS320F28377D: How to check CAN message has been sent before writing message object ?

Part Number: TMS320F28377D

Hi,

So I have a message object which corresponds to some sort of acknowledgment in my protocol.

In a certain condition, I can have that message being not succcessfull due to other messages being sent by other transmitter on the bus (priority).

However, it can happen that this acknowledgment is never sent due to me rewriting new data in that message object before it is effectively sent so it's another acknowledgment (the one after in our code) that gets sent.

My transmission function is below.

How do I check before writing to the transmission message that the data has been effectively sent ?

It's a little mystical for me in the documentation.

void CAN_sendMessage32(volatile struct CAN_REGS * CanRegs, uint32_t msgObjNum, uint32_t * data)
{
    // Use a Shadow variable for IF1CMD to prepare the data to perform a single 32-bit write.
    union CAN_IF1CMD_REG CAN_IF1CMD_SHADOW;

    // Wait for busy bit to clear.
    while(CanRegs->CAN_IF1CMD.bit.Busy) {}

    // Write data to transfer into DATA-A and DATA-B interface registers
    CanRegs->CAN_IF1DATA.all = data[0];
    CanRegs->CAN_IF1DATB.all = data[1];

    // Set Direction to write and set DATA-A/DATA-B to be transfered to message object
    CAN_IF1CMD_SHADOW.all           = 0;
    CAN_IF1CMD_SHADOW.bit.DIR       = 1;
    CAN_IF1CMD_SHADOW.bit.DATA_A    = 1;
    CAN_IF1CMD_SHADOW.bit.DATA_B    = 1;

    // Set Tx Request Bit to ask for transmission
    CAN_IF1CMD_SHADOW.bit.TXRQST    = 1;

    // Transfer the message object to message object RAM.
    CAN_IF1CMD_SHADOW.bit.MSG_NUM   = msgObjNum;
    CanRegs->CAN_IF1CMD.all         = CAN_IF1CMD_SHADOW.all;
}

Thanks,

Clément

  • Clement,

                Essentially what you are asking is how to ascertain completion of transmission. Is this correct? From the TRM: 

    After a successful transmission and if no new data was written to the message object (NewDat = '0') since the start of the transmission, the TxRqst bit will be reset. If TxIE is set, IntPnd will be set after a successful transmission.

     You could poll the TxRqst bit to ensure transmission completion or an interrupt (if enabled) will inform you of that condition. Does that help?

  • Hi,

    I didn't catch you were talking about the field from the register.

    I thought it was the TxRqst bit from the message transfered from command memory to CAN controller.

    All good now thanks.

    Clément