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.

TMS570LS3137 DCAN module - dynamic ID



Hi,

I have some problems configuring a routine to manage dynamically the transmission ID.  I had been reading the TMR and forum's posts about the dynamic ID, but I can't configure it properly.

I find in the TMR, that you can change the ID without clearing MsgVal, so I copied the canTransmit() routine and I had modified it to change IF1ARB register ID bits. But the function does not change the ID in the transmission frame. The trasmission frame has the same ID that I choice in the canInit() routine.

How can I do it?

New routine:

uint32 canTransmitID(canBASE_t *node, uint32 messageBox, const uint8 * data,uint16 id)
{
uint32 i;
uint32 success = 0U;
uint32 regIndex = (messageBox - 1U) >> 5U;
uint32 bitIndex = 1U << ((messageBox - 1U) & 0x1FU);
static uint16 idPrevious = 13;

/** - Check for pending message:
* - pending message, return 0
* - no pending message, start new transmission
*/
if ((node->TXRQx[regIndex] & bitIndex) != 0U)
{
success = 0U;
}

else
{
/** - Wait until IF1 is ready for use */
while ((node->IF1STAT & 0x80U) ==0x80U)
{
} /* Wait */

/** - Copy TX data into IF1 */

for (i = 0U; i < 8U; i++)
{


#ifdef __little_endian__
node->IF1DATx[i] = *data++;
#else
node->IF1DATx[s_canByteOrder[i]] = *data++;
#endif
}

/** - Change ID */
node->IF1ARB &= ~ididPrevious ;
node->IF1ARB |= (id & 0x1FFFFFFFU) << 0U;

/** - Copy TX data into message box */
node->IF1NO = messageBox;

success = 1U;
}
/** @note The function canInit has to be called before this function can be used.\n
* The user is responsible to initialize the message box.
*/


idPrevious  = id;

return success;
}