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.

CCS/HALCOGEN: Possible Bug: HalCoGen 4.6.1[4.6.0 according to about box] generates code to collect CAN message identifier incorrectly when non-extended frames are configured

Part Number: HALCOGEN

Tool/software: Code Composer Studio

For RM46, HalCoGen generates a function called getCanID.  That code collects the message identifier as if it were an extended ID.  When configured to be non-extended that means the 11 bit message identifier value is shifted to the left as if it were a 29 bit identifier.

*/

/* SourceId : CAN_SourceId_026 */

/* DesignId : CAN_DesignId_020 */

/* Requirements : HL_SR537 */

uint32 canGetID(canBASE_t *node, uint32 messageBox)

{

uint32 msgBoxID = 0U;

 

/** - Wait until IF2 is ready for use */

while ((node->IF2STAT & 0x80U) ==0x80U)

{

} /* Wait */

/** - Configure IF2 for

* - Message direction - Read

* - Data Read

* - Clears NewDat bit in the message object.

*/

node->IF2CMD = 0x20U;

/** - Copy message box number into IF2 */

/*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */

node->IF2NO = (uint8) messageBox;

/** - Wait until data are copied into IF2 */

while ((node->IF2STAT & 0x80U) ==0x80U)

{

} /* Wait */

/* Read Message Box ID from Arbitration register. */

msgBoxID = (node->IF2ARB & 0x1FFFFFFFU);

return msgBoxID;

}

  • Hi Neil,

    The function is simply reading the content of the IF2ARB register bit0-bit28 which is the ID location in the IF2 register. If standard length IDs are used only bits 28-18 are valid and if using extended length IDs, the full 29 bits are valid. Since the function is intended to be a generic function to be used in either standard or extended frame modes, it returns the full ID field of the register. If you are using standard frame lengths, you will need to perform a shift to move the bits to their appropriate bit locations for a more human readable value.

    Below is the definition of the register.

  • I see that the Standard Frame Message Identifier can reside in 28:18 bits on the register.

    I suggest that the HalCoGen function (canGetID), which is generated code, would perform the shift for the returned value (based on the Xtd bit at 30).