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.

[FAQ] How do I use C2000Ware files in a SYS/BIOS project?

Other Parts Discussed in Thread: C2000WARE

How do I use C2000Ware header files and libraries and SYS/BIOS in the same project?

  • Project Configuration

    To create a SYS/BIOS project that uses C2000Ware device support files, it is generally recommended to start with a SYS/BIOS example or template project and add support for C2000Ware to it. In C2000Ware under your device's device_support/<device>/docs/ directory, there is a firmware development user's guide that contains step-by-step instructions for creating a new non-SYS/BIOS project. Many of the same instructions can be used to guide you through what files, path variables, include path directories, predefined symbols, etc...need to be added to the SYS/BIOS project you've chosen has your starting point.

    Another option is to import an existing C2000Ware example and use it as a source from which you can copy the above items to your SYS/BIOS project. I've shown below the SYS/BIOS "Minimal" template project (see instructions on importing SYS/BIOS examples and templates here) into which I've integrated the F2837xD driverlib and other device support files. The exact files and settings will be different for you depending on your device and starting example.

    Files copied in the Project Explorer:

    Include Options and Predefined Symbols:

       

    Also check other options like Linked Resources/Path Variables, Processor Options, and the various linker options.

    A few things to note:

    • In my example above, I've used the FLASH linker command file from the C2000Ware example and removed the original cmd file. You can choose either one but they will conflict if you keep both.
    • I did not copy the CodeStartBranch.asm file--the Boot module "Enable boot from FLASH" option will serve the same purpose. Again, you will likely get linker errors if you try to keep them both.
    • By default, the C28x SYS/BIOS examples use COFF. You can change the ABI setting to EABI if preferred.

    Once you you've copied over all the appropriate files and build options, try building. You may need to resolve some linker errors if sections are missing (like .binit) or don't fit into the default range. If you are not familiar with editing linker command files, please see this document for information to get you started.

    If you're getting linker errors in the SYS/BIOS-generated linker.cmd file, this is likely related to "Flash Functions" settings. Open your project's .cfg file and edit the Boot module settings to use RAM and FLASH range names that are defined in your .cmd file. In my example, I matched my load/run memories to the same ones my .cmd file was using for .TI.ramfunc. In the cfg script it looks like the following:

        Boot.loadSegment = "FLASHD PAGE = 0";
        Boot.runSegment = "RAMLS0 PAGE = 0";

    Writing Application Code

    When you start adding your C2000Ware function calls and header files to the SYS/BIOS project, there are a few resource considerations you need to keep in mind.

    System clock

    By default the SYS/BIOS Boot module will configure the SYSCLK rate. If your application code is also calling Device_init() or InitSysCtrl() you may end up with issues related to this redundant reconfiguration. I recommend disabling this option in your .cfg file and using the C2000Ware function to configure the clock since C2000Ware is updated more frequently and will have the latest clock configuration procedure. Note that you'll still need to tell BIOS what the SYSCLK frequency is so that its Clock tick can be configured accurately. In the cfg script it looks like the following:

        Boot.configureClocks = false;
        BIOS.cpuFreq.lo = 200000000;

    Interrupts

    SYS/BIOS's Hwi module should be used to manage your interrupts. Therefore, you generally shouldn't write code in your application to configure the PIE vector table, PIE registers, or interrupt-related CPU registers and risk overwriting configurations needed by the Hwi module. Examples include functions like Interrupt_initVectorTable(), Interrupt_register(), or InitPieVectTable(). Instead create Hwis for your interrupts and call the SYS/BIOS Hwi module functions if updates need to be made.

    Do note that although SYS/BIOS will configure the PIE and CPU registers, it is not aware of the peripheral-level interrupt registers/bits (SPICTL.SPIINTENA, ETSEL.INTEN, etc...). You will still need to perform those configurations in your code. Also recall that Hwi functions do not require the __interrupt keyword, unlike regular non-BIOS ISRs.

    Timers

    The SYS/BIOS Clock module uses one of the device's CPU Timers to run its system tick. Similarly if you are using the Timestamp module, it may also use another CPU Timer. If you need to use a CPU Timer in your application, make sure it is not already in use by one of these modules.

    For more details about SYS/BIOS Timer use and other C28x-specific SYS/BIOS items, see this FAQ thread.

    Combined SYS/BIOS "Minimal" and C2000Ware led_ex1_blinky example source:

    /*
     *  ======== main.c ========
     */
    
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    #include "device.h"
    
    /*
     *  ======== taskFxn ========
     */
    Void taskFxn(UArg a0, UArg a1)
    {
        for(;;)
        {
            //
            // Turn on LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
    
            //
            // Delay for a bit.
            //
            Task_sleep(500);
    
            //
            // Turn off LED
            //
            GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
    
            //
            // Delay for a bit.
            //
            Task_sleep(500);
        }
    }
    
    /*
     *  ======== main ========
     */
    Int main()
    { 
        /*
         * use ROV->SysMin to view the characters in the circular buffer
         */
        System_printf("enter main()\n");
    
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // 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);
    
        BIOS_start();    /* does not return */
        return(0);
    }