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.

TMS320F28388D: Swapping GPIO/CAN functionality from MCAN to regular CAN and vice versa during runtime

Part Number: TMS320F28388D

Hello,

We have an application which needs to support MCAN or DCAN on the same set of GPIOs such that the functionality can be swapped from one to other during runtime. The swap will only happen once after startup, depending a program branch, so it doesn't need to be restarting over and over. I am able to set up independently either MCAN or DCAN and get it run, but I haven't been able to figure out how to switch the pins from MCAN to DCAN, or vice versa, without needing to power reset the device. 


Can you please list the steps needed to shutdown one CAN controller connected to a pair of GPIO and then reintialize the GPIO to a different CAN controller. For example GPIO 8,10 is initially set up as MCAN TX,RX and switch over to CANB TX,RX.

Everything is on CPU1 and not through the CM. 

Thanks,
Jason

  • Hi Jason,

    There is no need to shut down the DCAN or CAN-FD modules since these are independent IPs in the F28388 device. What you can do is initialize these CAN IPs independently, like how they are done in the examples but do not start the communications yet.  In DCAN, do not execute the API CAN_startModule() and do not define the CAN GPIO functions.  In CAN-FD, follow the same initialization steps as the MCAN examples but do not bring the MCAN out of SW initialization mode by not executing MCAN_setOpMode(base, MCAN_OPERATION_MODE_NORMAL) and also not defininf the CAN-FD GPIO functions yet.

    Once you get to the part of the application where you are ready to decide which module to operate, then that will be the time to define the CAN GPIO function then enable the CAN module for normal operation.  In DCAN you can follow below:

        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
        CAN_startModule(CANA_BASE);
    In MCAN you can have this sequence:
        GPIO_setPinConfig(DEVICE_GPIO_CFG_MCANRXA);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_MCANTXA);
       MCAN_setOpMode(MCANA_DRIVER_BASE, MCAN_OPERATION_MODE_NORMAL);
    You can implement this as if-else statement so only one CAN module and GPIO set is enabled at a time.
    Another alternative is just to just use MCAN.  MCAN has the ability to operate as classic CAN through the FDOE bit.  See example mcan_ex7_classic_transmit if you want to check out this feature.
    Hope the pointers above will help.
    Regards,
    Joseph
  • Hi Joseph,

    Sorry for delay. Thank you for the implementation steps. 

    Just for completeness, is there a way to swap functionality (MCAN -> DCAN, vice versa) after one set of GPIO has been set up and the module has been started, or is a power cycle generally required?

  • Hi Jason,

    No, power cycle is not required.  Key is to configure GPIO functionality to either MCAN or DCAN whenever you need to use the channels accordingly.

    Regards,

    Joseph