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.

TMS320F28379D: CAN MailBox Id Modification when programm running

Part Number: TMS320F28379D
Other Parts Discussed in Thread: SYSCONFIG

Hello,

I want to change the Id of a MailBox while the programm is running.

I looked at what SysConfig generates for the initialization in board_init():

  • the initialization of the whole MailBox thanks to CAN_setupMessageObject()
  • the start of the module thanks to CAN_startModule()

So, my idea was 

  • to stop the module
  • the initialze the mailbox, changing the Id

But the function CAN_stopModule() does not exist.

What do you suggest ? To write a such function by my own ? Is there any other risk to change the Id with this method ?

Thank you for your advice

Vincent

 

 

 

 

  • Hello,

    Apologies for the delay, Monday was a holiday in the US. Please expect a reply shortly.

    Best,
    Matt

  • Hey Vincent,

    There is no CAN_stopModule(), there is a CAN_disableController() function that could implement this function for you.

    However, 

    The safest approach is to disable only the specific mailbox you want to modify, rather than stopping the entire CAN module:

    Disable the mailbox by clearing the MsgVal bit (bit 31) to 0 in the CAN_IF1ARB register. When disabled, the message object is ignored by the message handler.
    Modify the ID by updating the ID bits (28:0) within the CAN_IF1ARB register.
    Re-enable the mailbox by setting the MsgVal bit back to 1.
    You can use the Driverlib function CAN_setupMessageObject() to reconfigure the mailbox with the new ID. The library also provides CAN_disableMessageObject() if you need to explicitly disable a message object.

    To modify a message object at runtime, you must use the CAN Interface (IFx) registers:

    1. Initiate a read transfer from the message object to the interface registers by writing the message number to the MSG_NUM field of the CAN_IFxCMD register.
    2. Wait for the Busy bit (bit 15) to clear. The interface registers are write-protected while this bit is set.
    3. Modify the data in the interface registers (including the ID in CAN_IF1ARB).
    4. Initiate a write transfer by setting the DIR bit to 1 and ensuring the Arb bit (bit 21) is set to transfer the arbitration fields back to the message object.
    5. The CAN_setupMessageObject() function handles this sequence for you.

    Let us know if this solution will properly address your issue here. We are glad to provide further help.

    Best Regards,

    Zackary Fleenor

  • Hello Zackary,

    Thanks a lot for your explanation, very clear.

    So, could you just confirm that these two lines  meet my need:

    (assuming that the object 2 was configured with Id 983 in board_init())

    (I did test, it seems to be OK)

    I will not forget to close this issue.

    Bye

  • Hey Vincent,

    This looks correct to me, assuming you re-enable the message object afterwards. Glad to hear the testing went according to plan!

    Sounds like we can close this issue in the meantime. If anything else comes up, feel free to create a new E2E thread and we will be glad to provide further assistance from there Slight smile.

    Best Regards,

    Zackary Fleenor