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.

LAUNCHXL-F28379D: CAN on Core 2

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Hello,

I have a big problem on a 2 cores application.

I started from the led blinking application, provided by TI.

I tried to add a CAN functionnality on the second core, using SySconfig. I put the example in attached files.

When I run the project in a debug session, I noticed that the programm on the Core 2 never goes out from the Board_init() function.

More exactly, the programm stops in the CAN_initRAM function:

Can anyone help me ?

2024_05_02_CANSupport_v2.zip

  • Vincent,

              Debugging your code is not something we can support on e2e. Hope the below pointers help you.

    You could start off with something very simple like a LED blinking code on both CPUs. See attached testcases for example. Once you get this running, you could replace the code on CPU2 with CAN code.

    5554.led_ex1_blinky_cpu1.c
    //#############################################################################
    //
    // FILE:   led_ex1_blinky_cpu1.c
    //
    // TITLE:  LED Blinky Example
    //
    //! \addtogroup driver_dual_example_list
    //! <h1> LED Blinky Example</h1>
    //!
    //! This example demonstrates how to blink a LED using CPU1 and blink another
    //! LED using CPU2 (led_ex1_blinky_cpu2.c).
    //!
    //! \b External \b Connections \n
    //!  - None.
    //!
    //! \b Watch \b Variables \n
    //!  - None.
    //!
    //
    //#############################################################################
    //
    // 
    // $Copyright:
    // Copyright (C) 2013-2023 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
    #ifdef _STANDALONE
    #ifdef _FLASH
        //
        // Send boot command to allow the CPU2 application to begin execution
        //
        Device_bootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
    #else
        //
        // Send boot command to allow the CPU2 application to begin execution
        //
        Device_bootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
    
    #endif // _FLASH
    #endif // _STANDALONE
    
        //
        // Initialize GPIO and configure the GPIO pin as a push-pull output
        //
        Device_initGPIO();
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
    
        //
        // Configure CPU2 to control the LED GPIO
        //
        GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU2);
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // Loop Forever
        //
        for(;;)
        {
            //
            // Turn on LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
    
            //
            // Delay for a bit.
            //
            DEVICE_DELAY_US(500000);
    
            //
            // Turn off LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
    
            //
            // Delay for a bit.
            //
            DEVICE_DELAY_US(500000);
        }
    }
    
    //
    // End of File
    //
    
    5554.led_ex1_blinky_cpu2.c
    //#############################################################################
    //
    // FILE:   led_ex1_blinky_cpu2.c
    //
    // TITLE:  LED Blinky Example
    //
    // <h1> LED Blinky Example (CPU2) </h1>
    //
    // This example demonstrates how to blink a LED using CPU2.
    //
    // \b External \b Connections \n
    //  - None.
    //
    // \b Watch \b Variables \n
    //  - None.
    //
    //
    //#############################################################################
    //
    // 
    // $Copyright:
    // Copyright (C) 2013-2023 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Initialize GPIO and configure the GPIO pin as a push-pull output
        //
        // This is configured by CPU1
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // Loop Forever
        //
        for(;;)
        {
            //
            // Turn on LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
    
            //
            // Delay for a bit.
            //
            DEVICE_DELAY_US(500000);
    
            //
            // Turn off LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
    
            //
            // Delay for a bit.
            //
            DEVICE_DELAY_US(500000);
        }
    }
    
    //
    // End of File
    //
    

  • Is the CAN clock enabled in CPU2? If CAN clock is not enabled before calling CAN_InitRAM(), the code may be stuck in the while loop.

  • Debugging your code is not something we can support on e2e

    Hello. I understand and that's exactly what I did below:

    1- To load the example provided by TI into a new CCS  session

    2- To Check that le led are blinking (FLASH configuration in a debug session for that example) --> OK

    3- To add a CAN peripheral in the SysConfig File on CPU2. I DID NOT PUT any code. I even did not asked for mailboxes configuration in SysConfig

    4- To launch again a debug session --> NOK.

    You can try to do this, and will see that you will never go out from the CAN_initRAM function

  • Hello.

    It seems to be interesting. As you can see just above, I replied to Hareesh: I just load an example provided on the TI website and added a CAN functionnality in SysConfig and this example does not work anymore.

    What should I do enable clock RAM on CPU2 ?

    In the exemple provided by TI:

    - in Device_init() (called at the beginning of the code) I found this, which makes me think that the clock is enabled:*

    - in SysConfig I checked the box "Start CAN"

    That causes the initialization of CAN_CTL_INIT and CAN_CTL_CCE Registers.

    Do you have something more to propose ?

    Many thanks.

    Vincent

  • Hi Vincent,

    The code looks ok to me. Have you tried the same code on CPU core 1? 

  • Hi,

    Did you try to run the code on a LAUNCHXL ?

    I join the TI example with the CAN on CPU2. Can you test it and tell me if you reproduce this behaviour ?

    (This code cannot be used in the Standalone mode, please run it in a debug session)

    - without CAN (exactly as dowloaded in TI website): the 2 led are blinking

    - I open the sysconfig file and add a CAN on CPU2, just to initialise the peripheral

    As described before, the code stops into the initialization

    - To answer to your question, I did the same thing on CPU1:

    Everything is OK.

    2024_05_13_CANInitCPU2TI.zip

  • Hello QJ,

    Did you see my first answer ? I ve no news from new and you are my only hope. This issue is serious for my project.

    Thnak you in advance.

    Vincent

  • Sorry to bother you with that issue.

    I don't know if you saw my first reply: to add the CAN peripheral on a TI example is what I did (see below). It does not work. My project is on stand by. I really need to code the CAN stack on CPU2.

    Can you try just to add CAN with SysConfig on the led_ex2_sysconfig TI example ?

  • Hi Vincent,

    I am new to C2000 devices, and haven't got a launchpad for testing. If you comment out the CAN_initRAM(base), can you send and receive CAN messages?

  • Hello,

    No, I did not try, because I wanted to do exactly as TI advises.

    Also, I wonder how CAN could work without this function (if it exists, it has to be usefull). I will try it but please please, can you get a launchpad and do the test ? (even if commenting the CAN_initRAM allows me to send messages, this solution cannot be implemented in the project, because we will not be sure that nothing wrong will happen in the future)

    Again, I did just as TI ask to do: download an example, the add a functionnality, without any user code. I expected that TI would support me Disappointed

    I really hope you will come back to me very soon. I have to tell to the team if CAN functionnality is OK on the second core at the end of the week.

    edit: I just tried to comment the command CAN_initRAM(). Since it belongs to the DriverLib Library, this comment seems to be not taken into account; Down below: the code enters in CAN_InitRAM

    Anyway, changing the contents of DriverLib was not acceptable

  • Hi Vincent,

    Did you select CPU2 for CAN module (CAN_A or CAN_B) used in your code? The CAN module can be connected to either CPU1 or CPU2, but cannot be used by both cores simutaneously. 

    The core selection can be done in CPU1 by writing 0x1 to CPUSEL8 register to connect CAN_A to CPU2. By default, CAN_A and CAN_B are connected to CPU1.

  • Hello,

    1) Declaring CAN on CPU2 section of SysConfig, I expected that there is somexhere in the BoardInint() function that configures this bit in CPUSEL8 Register

    2) Since TI example does not include BitFields, I am forced to use one of my code, which includes bitfields (I added bitfield files in the TI example)

    In the CPU1 project, I added this line:

    The only thing I can say is that the code is actually not blocked into the RAM initialization. I will not able to test the CAN till tomorrow, I will let oy know if I can receive and tranmitt messages

    3) Again, TI recommands to use DriverLib, not BitFields anymore. What is the DriverLib function which allows to set the CPUSEL8 bits ? Why SysConfig does not generates the corresponding lines ?

    I am afraid that, if I have a problem in the future (an I will have), I cannot reproduce it on a TI example because TI examples does not deal with bitfields anymore. Then, TI will answer "consider our example, we cannot debugging your code"

  • There is an API in the DriverLib to select CPU for CAN:

    The API is in file: C:\ti\c2000\C2000Ware_5_02_00_00\driverlib\f2837xd\driverlib\sysctl.h, line: 2984 

    static inline void SysCtl_selectCPUForPeripheral(SysCtl_CPUSelPeripheral peripheral, uint16_t peripheralInst, SysCtl_CPUSel cpuInst)

  • Hello QJ.

    I want to thank you for your support. This resolved my issue.

    I hope we will discuss again.

    Have a nice day