Skip to content

Refined CAN Settings Logic in the Code#37

Open
MaRuolang wants to merge 1 commit intoOpenNuvoton:masterfrom
MaRuolang:fix-can-rx-msgobj-setting
Open

Refined CAN Settings Logic in the Code#37
MaRuolang wants to merge 1 commit intoOpenNuvoton:masterfrom
MaRuolang:fix-can-rx-msgobj-setting

Conversation

@MaRuolang
Copy link
Copy Markdown

This pull request improves the logic related to CAN configuration, specifically correcting the misuse of mask settings and simplifying the setup for message objects. The changes include:

Modification 1: The CAN_SetRxMsgObj function no longer incorrectly sets the UMASK bit in the CAN_IFn_MCON register, aligning with the chip manual's guidance.

Modification 2: The CAN_SetRxMsgObjAndMsk function has been updated for clarity, making the setup for standard and extended frame IDs more intuitive.

Before and After:

  • Standard ID Setup:

    • Before: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, (0x00F << 2) << 16, TRUE);
    • After: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_STD_ID, 0x003, 0x00F, TRUE);
  • Extended ID Setup:

    • Before: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_EXT_ID, 0x00000003, CAN_IF_MASK2_MXTD_Msk | 0x0000000F, TRUE);
    • After: CAN_SetRxMsgObjAndMsk(tCAN, MSG(0), CAN_EXT_ID. 0x00000003, 0x0000000F, TRUE);

These updates ensure the CAN configuration is both correct and user-friendly, adhering closely to the intended design and documentation.

1. Remove incorrect UMask bit setting in CAN_IFn_MCON within CAN_SetRxMsgObj.
2. Align CAN_IFn_MASK setting logic with CAN_IFn_ARB in CAN_SetRxMsgObjAndMsk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant