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.

TMS570LC4357: Reconfigure CAN Message Box using canUpdateID function

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

I would like to reconfigure CAN Message Boxes for transmit and receive.

Question 1: 

In the canUpdateID function, what is the purpose of node->IF2CMD = 0xA0U; ?

0xA0 only affects ID fields, why are we writing 0xA0 in the ID field?

Question 2:

I had to modify the canUpdateID message to accommodate some of the register file changes, I have tried to assign values to the registers as the HALCOGEN generated code as shown below. But it doesn't work. The second message that I am trying to transmit after updating the ID of the object is not getting transmitted. Moreover, I see in debug mode that the values are not getting written to the registers. Does the IF2 register have any write-protect settings?

void canUpdateID(canBASE_t *node, bool isTx, uint32 messageBox, uint32 can_id)
{

    /** - Wait until IF2 is ready for use */
    while((*node).CAN_IF2CMD.bit.Busy)
    {
    } /* Wait */

    /** - Configure IF2 for
    *     - Message direction - Read
    *     - Data Read
    *     - Clears NewDat bit in the message object.
    */
    //(*node).CAN_IF2CMD.all = 0xA0U;
    //
    // Set direction to transmit
    //
    if(isTx)
    {
        (*node).CAN_IF2CMD.bit.DIR = 1U;
    }
    else
    {
        (*node).CAN_IF2CMD.bit.DIR = 0;
    }
    (*node).CAN_IF2CMD.bit.TxRqst = 0;

    /* Copy passed value into the arbitration register. */
    //(*node).CAN_IF2ARB.all &= 0x80000000U;
    (*node).CAN_IF2ARB.bit.MsgVal = 1;

    //node->CAN_IF2ARB.all |= (msgBoxArbitVal & 0x7FFFFFFFU);
    (*node).CAN_IF2ARB.bit.MsgVal = 0;
    if(isTx)
    {
        (*node).CAN_IF2ARB.bit.Dir = 1U;
    }
    else
    {
        (*node).CAN_IF2ARB.bit.Dir = 0;
    }

    (*node).CAN_IF2ARB.bit.ID = can_id << CAN_IF1ARB_STD_ID_S;

    /** - Update message box number. */
    /*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */
    (*node).CAN_IF2CMD.bit.MSG_NUM = messageBox;

    /** - Wait until data are copied into IF2 */
    while((*node).CAN_IF2CMD.bit.Busy)
    {
    } /* Wait */

}
 

Regards,

Rashmitha

  • Hi Rashmitha,

    In the canUpdateID function, what is the purpose of node->IF2CMD = 0xA0U; ?

    0xA0 only affects ID fields, why are we writing 0xA0 in the ID field?

    Maybe you are confused. IF2CMD means not the ID field.

    Here we are dividing IF2CMD register into 4 characters as shown below:

    So here we are writing in the IF2CMD field. That means below highlighted bits will be affected:

    I had to modify the canUpdateID message to accommodate some of the register file changes, I have tried to assign values to the registers as the HALCOGEN generated code as shown below. But it doesn't work. The second message that I am trying to transmit after updating the ID of the object is not getting transmitted. Moreover, I see in debug mode that the values are not getting written to the registers. Does the IF2 register have any write-protect settings?

    Let me explain what exactly we are doing in HALCoGen for to update the ID:

    1. 

    while ((node->IF2STAT & 0x80U) ==0x80U)
        {
        } /* Wait */

    The above instruction is used to wait until the IF2 is busy.

    2. 

    node->IF2CMD = 0xA0U;

    In the above instruction we are setting the WR/RD bit and the Arb bits.

    That means we are telling CAN module that we want to do the write operation to the message RAM and also we are telling we want to update the arbitration field(Identifier + Dir + Xtd + MsgVal).

    3.

    node->IF2ARB &= 0x80000000U;
    	node->IF2ARB |= (msgBoxArbitVal & 0x7FFFFFFFU);

    In these two instructions we are updating arbitration field with the new required ID etc.

    4.

    node->IF2NO = (uint8) messageBox;

    As we already updated the new ID into the arbitration field, and now using this instruction we are initiating the actual writing into the message RAM for corresponding message box.

    5.

     while ((node->IF2STAT & 0x80U) ==0x80U)
        {
        } /* Wait */

    waiting until he updation completion.

    --

    Thanks & regards,
    Jagadish.