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/TMS320F28379D: CAN bus assigned to CPU2

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi all.

I want use the CANB from CPU2. I started from a working code for CPU1 and modified it for dual core applications (ControlSuite library).

The CPU1 initializes the system and the GPIO, then assign the peripheral to the CPU2 as follow:

 

//  Main function

int main(void)

{

//    struct PCLKCR10_BITS CPUSEL8_conn;

    // Initialize System Control

    InitSysCtrl();

    InitGpio();

    GPIO_SetupPinMux(17, GPIO_MUX_CPU2, 2); //GPIO10 -  CANRXB

    GPIO_SetupPinOptions(17, GPIO_INPUT, GPIO_ASYNC);

    GPIO_SetupPinMux(12, GPIO_MUX_CPU2, 2);  //GPIO8 - CANTXB

    GPIO_SetupPinOptions(12, GPIO_OUTPUT, GPIO_PUSHPULL);

 

    DINT;

 

    InitPieCtrl();

 

    IER = 0x0000;

    IFR = 0x0000;

 

    InitPieVectTable();

    /*

     *  Transfer ownership of CAN BUS to CPU02

     *  e2e.ti.com/.../623258

     *  CPU control. Defines the owner

     *  0: Connected to CPU1

     *  1: Connected to CPU2

     */

    EALLOW;

    DevCfgRegs.CPUSEL8.bit.CAN_B = 1; //CPU2 is the owner

    EDIS;

 

 

    while(1){;}

 

The CPU2 configure the CAN bus device and use it. Hereafter is reported the CPU2 init code.

 

int main(void)

{

    uint32_t status;

 

 

    InitSysCtrl();   // Initialize System Control and clock

 

    DINT;    // Disable CPU interrupts

 

    InitPieCtrl(); // Initialize PIE control registers to their default state.

 

    //

    // Disable CPU interrupts and clear all CPU interrupt flags:

    //

        IER = 0x0000;

        IFR = 0x0000;

 

    //

    // Initialize the PIE vector table with pointers to the shell Interrupt

    // Service Routines (ISR).

 

        InitPieVectTable();

 

    // uses CANB

    CANInit(CANB_BASE);

//-------------------

    // CANClkSourceSelect(CANB_BASE, SOURCE);

    // select the SOURCE input as follow:

    //!        0 - Selected CPU SYSCLKOUT (CPU1.Sysclk or CPU2.Sysclk)

    //!           (default at reset) \n

    //!        1 - External Oscillator (OSC) clock (direct from X1/X2) \n

    //!        2 - AUXCLKIN = GPIOn(GPIO19)

 

    CANClkSourceSelect(CANB_BASE, 0);   // 500kHz CAN-Clock

    CANBitRateSet(CANB_BASE, 200000000, 500000);

    //

    // Power up the CAN bus

    //

        EALLOW;

        CpuSysRegs.PCLKCR10.bit.CAN_B = 1;

        EDIS;

 

(… configure packets and transmit/receive.)

 

From examples, reference manual and datasheet I cannot understand why I cannot communicate with it. The test is executed with a LaunchPad - F28379D development kit.

Thanks,

  Luigi

  • Hi Luigi,

    The CPU1 code looks correct.  CANTX and RX pins are correctly mapped with GPIO functions for GPIO12 and GPIO17 on CPU1 as the case should be.  The only thing I see that might be incorrect on the CPU2 code is turning on the peripheral clock for CANB.  Before any register writes are allowed, the peripheral clock to a module must be turned on first.  Try moving the statements:

     

     EALLOW;

     CpuSysRegs.PCLKCR10.bit.CAN_B = 1;

     EDIS;

    before calling any of the CAN functions.  In this case, move the above statements after  InitPieVectTable();

     

    Hope this helps.

    Regards,

    Joseph

     

  • It works!  Thanks

    Regards

       Luigi