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: Passing specific CAN peripheral from CPU1 to CPU2

Part Number: TMS320F28388D

Hi expert,

We are modifying example project "cm_common_config_c28x.c" to pass control of CAN peripheral to CPU2 and we are targeting to let CPU2 use CANB. We configured like this but seems not success. (CPU2 CANB initialization failed).

1. Do we offer any example show case of how to assign peripheral from CPU1 to CPU2 correctly? It seems using differnent API against passing peripheral to CM core.

2. Could you let us know if we did it correctly? If not, could you help us to do it right? (As shown below)

#ifdef CANB
    //
    // Configuring the GPIOs for CAN B.
    //
    GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
    GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);

    //
    // Allocate Shared Peripheral CAN B to the CM Side.
    //
    //SysCtl_allocateSharedPeripheral(SYSCTL_PALLOCATE_CAN_B,0x1U);
    SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL8_CAN,1,SYSCTL_CPUSEL_CPU2);
#endif

Thanks

Sheldon

  • Hi Sheldon,

    Let me answer the post differently and let me know if this makes sense:

    1.  Allocation of core to a peripheral can only be done in CPU1.
      1. If allocating peripheral to CPU2, use driver function SysCtl_selectCPUForPeripheral();
      2. If allocating peripheral to CM, use driver function SysCtl_allocateSharedPeripheral() which is found in cm_common_config_c28x.c file
    2. Above driver functions do not enable the peripheral clock.  You should do this separately for each peripheral so that register writes to those peripherals (like init bit setting) will take place.  Use driver function SysCtl_enablePeripheral() to do this and this function can be called from the core that the peripheral is assigned to (example: when CANB is allocated to CPU2, you can call SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CANB) and this should allow writing to CANB registers like the initi bit in CAN_CTL)

    As best practice, first disable the peripheral clock for a module before assigning module allocation in step# 1.

    Best regards,

    Joseph 

  • Hi Joseph,

    Here is my feedback on your answer:

    1.  Allocation of core to a peripheral can only be done in CPU1.
      1. If allocating peripheral to CPU2, use driver function SysCtl_selectCPUForPeripheral();
      2. If allocating peripheral to CM, use driver function SysCtl_allocateSharedPeripheral() which is found in cm_common_config_c28x.c file

      Sure, we are using this API in CPU1 to do the asignment. But this API can only be passed with parameter "SYSCTL_CPUSEL8_CAN" which didn't specify which CAN moduel is targeted (CANA or CANB). 

    2. Above driver functions do not enable the peripheral clock.  You should do this separately for each peripheral so that register writes to those peripherals (like init bit setting) will take place.  Use driver function SysCtl_enablePeripheral() to do this and this function can be called from the core that the peripheral is assigned to (example: when CANB is allocated to CPU2, you can call SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CANB) and this should allow writing to CANB registers like the initi bit in CAN_CTL)

    We are using example project "can_ex5_transmit_receive.c" on CPU2, and all the peripherals are enabled here with the API you mentioned. In this case, CANA's register and be written in CPU2 while CANB can not. 

     

    Now, My cusotmer and I can both reproduce this issue based on tiny modification on TI example project. And this issue only happens on CANB, not CANA. So we don't have any idea of what to do next.

    I can send you this test program to you through TI drive. They can be easily reproduced on TI LP. Could you help us get the answer?

    Thanks

    Sheldon

     

  • Hi Sheldon,

    Sorry for the late response.I think the issue in customer's code is that in the function call SysCtl_selectCPUForPeripheral(), the 2nd argument is '1'.  It should be '2' so it will properly allocate CANB to CPU2.  Here is the simplified code that i tried out based from what you sent:

    In CPU1, try this basic code in order to allocate CANB to CPU2:

       //
        // Initialize device clock and peripherals
        // Device_init() has the function Device_enableAllPeripherals() that turns on clock for all peripherals including CANA and CANB
        Device_init();
    
        //
        // Configuring the GPIOs for CAN B.
        //
        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
    
        //SysCtl_resetPeripheral(SYSCTL_PERIPH_RES_CANB);
        //
        // Allocate Shared Peripheral CAN B to the CM Side.
        //
        SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL8_CAN,2,SYSCTL_CPUSEL_CPU2);
         :
         :

    In CPU2, try this basic code to configure CANB:

        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Initialize the CAN controller
        //
        CAN_initModule(CANB_BASE);
    
        //
        // Set up the CAN bus bit rate to 500kHz
        // Refer to the Driver Library User Guide for information on how to set
        // tighter timing control. Additionally, consult the device data sheet
        // for more information about the CAN module clocking.
        //
        CAN_setBitRate(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 20);
           :
           :

    Let me know if this works.

    Regards,

    Joseph