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.

RTOS/CC2650MODA: Jitter of Timer module

Part Number: CC2650MODA
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi all,

I need to generate a clock signal with a maximum jitter less than 10us. For this I configured in TIRTOS (cc13xx_cc26xx_2_16_00_08) a Timer instance to fire each 5ms and an Hwi function associated with the timer  which toggles a GPIO. To debug the jitter i have only one dummy task which runs in my configuration.

I observed that if I force a "while(1);" in the task, the GPIO toggle is really accurate. Conversely if I use Task_sleep() i measured a jitter of +- 30us. The thinks make dramatically worse if i use more tasks.

Now, If the timer should use the 48MHz clcok of the CPU and hopefully not the RTC and since Hwi-s have the highest execution priority, why this really poor performance?

PL

  • PL,

    Do you have power management enabled in this application?  A first guess… with calling Task_sleep(), the difference you are seeing is because the power policy running in the Idle loop transitions the device to a lower power state, and that these transitions could explain the jitter you are seeing.

    Another guess is that the Task_sleep() call may be letting a lower priority task run, which has a critical section with Hwis disabled for a long duration, resulting in the jitter.

    Can you please post your application configuration file (the *.cfg file)?

    Thanks,
    Scott

  • Hi Scott,

    The power policy is disabled and the other tasks just increment variables than call Task_sleep too.

    Note that I have jitter even in the case of just one task running.

    I suspect that the jitter may be introduced by the Hwi kernel dispatcher itself due to recording of other interrupts (e.g. the timer used by the clock module). Is this something you expect?

    regards

    PL

    /*
     * Copyright (c) 2015-2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * 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.
     */
    
    
    
    /* ================ Boot configuration ================ */
    var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
    var Timer = xdc.useModule('ti.sysbios.hal.Timer');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    
    
    
    /* ================ Defaults (module) configuration ================ */
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    var HwiCommon = xdc.useModule('ti.sysbios.family.arm.HwiCommon');
    var Text = xdc.useModule('xdc.runtime.Text');
    var GateTask = xdc.useModule('ti.sysbios.gates.GateTask');
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    /*
     * A flag to allow module names to be loaded on the target. Module name
     * strings are placed in the .const section for debugging purposes.
     *
     * Pick one:
     *  - true (default)
     *      Setting this parameter to true will include name strings in the .const
     *      section so that Errors and Asserts are easier to debug.
     *  - false
     *      Setting this parameter to false will reduce footprint in the .const
     *      section. As a result, Error and Assert messages will contain an
     *      "unknown module" prefix instead of the actual module name.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Defaults.common$.namedModule = true;
    Defaults.common$.namedModule = false;
    
    
    
    /* ================ Error configuration ================ */
    var Error = xdc.useModule('xdc.runtime.Error');
    /*
     * This function is called to handle all raised errors, but unlike
     * Error.raiseHook, this function is responsible for completely handling the
     * error with an appropriately initialized Error_Block.
     *
     * Pick one:
     *  - Error.policyDefault (default)
     *      Calls Error.raiseHook with an initialized Error_Block structure and logs
     *      the error using the module's logger.
     *  - Error.policySpin
     *      Simple alternative that traps on a while(1) loop for minimized target
     *      footprint.
     *      Using Error.policySpin, the Error.raiseHook will NOT called.
     */
    //Error.policyFxn = Error.policyDefault;
    Error.policyFxn = Error.policySpin;
    
    /*
     * If Error.policyFxn is set to Error.policyDefault, this function is called
     * whenever an error is raised by the Error module.
     *
     * Pick one:
     *  - Error.print (default)
     *      Errors are formatted and output via System_printf() for easier
     *      debugging.
     *  - null
     *      Errors are not formatted or logged. This option reduces code footprint.
     *  - non-null function
     *      Errors invoke custom user function. See the Error module documentation
     *      for more details.
     */
    //Error.raiseHook = Error.print;
    Error.raiseHook = null;
    //Error.raiseHook = "&myErrorFxn";
    
    /*
     * If Error.policyFxn is set to Error.policyDefault, this option applies to the
     * maximum number of times the Error.raiseHook function can be recursively
     * invoked. This option limits the possibility of an infinite recursion that
     * could lead to a stack overflow.
     * The default value is 16.
     */
    Error.maxDepth = 2;
    /*
     * The Idle module is used to specify a list of functions to be called when no
     * other tasks are running in the system.
     *
     * Functions added here will be run continuously within the idle task.
     *
     * Function signature:
     *     Void func(Void);
     */
    //Idle.addFunc("&myIdleFunc");
    
    
    
    /* ================ Kernel (SYS/BIOS) configuration ================ */
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    /*
     * Enable asserts in the BIOS library.
     *
     * Pick one:
     *  - true (default)
     *      Enables asserts for debugging purposes.
     *  - false
     *      Disables asserts for a reduced code footprint and better performance.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //BIOS.assertsEnabled = true;
    BIOS.assertsEnabled = null;
    
    /*
     * Specify default heap size for BIOS.
     */
    BIOS.heapSize =4096; //10000; //4096; //1024;
    
    /*
     * Specify default CPU Frequency.
     */
    BIOS.cpuFreq.lo = 48000000;
    
    /*
     * A flag to determine if xdc.runtime sources are to be included in a custom
     * built BIOS library.
     *
     * Pick one:
     *  - false (default)
     *      The pre-built xdc.runtime library is provided by the respective target
     *      used to build the application.
     *  - true
     *      xdc.runtime library sources are to be included in the custom BIOS
     *      library. This option yields the most efficient library in both code
     *      footprint and runtime performance.
     */
    //BIOS.includeXdcRuntime = false;
    BIOS.includeXdcRuntime = true;
    
    /*
     * The SYS/BIOS runtime is provided in the form of a library that is linked
     * with the application. Several forms of this library are provided with the
     * SYS/BIOS product.
     *
     * Pick one:
     *   - BIOS.LibType_Custom
     *      Custom built library that is highly optimized for code footprint and
     *      runtime performance.
     *   - BIOS.LibType_Debug
     *      Custom built library that is non-optimized that can be used to
     *      single-step through APIs with a debugger.
     *
     */
    BIOS.libType = BIOS.LibType_Instrumented;
    //BIOS.libType = BIOS.LibType_Debug;
    
    /*
     * Runtime instance creation enable flag.
     *
     * Pick one:
     *   - true (default)
     *      Allows Mod_create() and Mod_delete() to be called at runtime which
     *      requires a default heap for dynamic memory allocation.
     *   - false
     *      Reduces code footprint by disallowing Mod_create() and Mod_delete() to
     *      be called at runtime. Object instances are constructed via
     *      Mod_construct() and destructed via Mod_destruct().
     *
     *  When using BIOS in ROM:
     *      This option must be set to true.
     */
    BIOS.runtimeCreatesEnabled = true;
    //BIOS.runtimeCreatesEnabled = false;
    
    /*
     * Enable logs in the BIOS library.
     *
     * Pick one:
     *  - true (default)
     *      Enables logs for debugging purposes.
     *  - false
     *      Disables logging for reduced code footprint and improved runtime
     *      performance.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //BIOS.logsEnabled = true;
    BIOS.logsEnabled = null;
    
    
    
    /* ================ Memory configuration ================ */
    var Memory = xdc.useModule('xdc.runtime.Memory');
    /*
     * The Memory module itself simply provides a common interface for any
     * variety of system and application specific memory management policies
     * implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
     */
    
    
    
    /* ================ Program configuration ================ */
    /*
     *  Program.stack is ignored with IAR. Use the project options in
     *  IAR Embedded Workbench to alter the system stack size.
     */
    if (!Program.build.target.$name.match(/iar/)) {
        /*
         *  Reducing the system stack size (used by ISRs and Swis) to reduce
         *  RAM usage.
         */
        Program.stack = 768;
    }
    
    
    
    /*
     * Uncomment to enable Semihosting for GNU targets to print to the CCS console.
     * Please read the following TIRTOS Wiki page for more information on Semihosting:
     * processors.wiki.ti.com/.../TI-RTOS_Examples_SemiHosting
     */
    
    if (Program.build.target.$name.match(/gnu/)) {
        //var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
    }
    
    /* ================ ROM configuration ================ */
    /*
     * To use BIOS in flash, comment out the code block below.
     */
     /*
    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    if (Program.cpu.deviceName.match(/CC26/)) {
        ROM.romName = ROM.CC2650;
    }
    else if (Program.cpu.deviceName.match(/CC13/)) {
        ROM.romName = ROM.CC1350;
    }*/
    
    
    
    /* ================ Semaphore configuration ================ */
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    /*
     * Enables global support for Task priority pend queuing.
     *
     * Pick one:
     *  - true (default)
     *      This allows pending tasks to be serviced based on their task priority.
     *  - false
     *      Pending tasks are services based on first in, first out basis.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Semaphore.supportsPriority = true;
    Semaphore.supportsPriority = false;
    
    /*
     * Allows for the implicit posting of events through the semaphore,
     * disable for additional code saving.
     *
     * Pick one:
     *  - true
     *      This allows the Semaphore module to post semaphores and events
     *      simultaneously.
     *  - false (default)
     *      Events must be explicitly posted to unblock tasks.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Semaphore.supportsEvents = true;
    Semaphore.supportsEvents = false;
    
    
    /* ================ Event configuration ================ */
    var Event = xdc.useModule('ti.sysbios.knl.Event');
    
    
    /* ================ Swi configuration ================ */
    var Swi = xdc.useModule('ti.sysbios.knl.Swi');
    /*
     * A software interrupt is an object that encapsulates a function to be
     * executed and a priority. Software interrupts are prioritized, preempt tasks
     * and are preempted by hardware interrupt service routines.
     *
     * This module is included to allow Swi's in a users' application.
     */
    
    /*
     * Reduce the number of swi priorities from the default of 16.
     * Decreasing the number of swi priorities yields memory savings.
     */
    Swi.numPriorities = 6;
    
    
    
    /* ================ System configuration ================ */
    var System = xdc.useModule('xdc.runtime.System');
    /*
     * The Abort handler is called when the system exits abnormally.
     *
     * Pick one:
     *  - System.abortStd (default)
     *      Call the ANSI C Standard 'abort()' to terminate the application.
     *  - System.abortSpin
     *      A lightweight abort function that loops indefinitely in a while(1) trap
     *      function.
     *  - A custom abort handler
     *      A user-defined function. See the System module documentation for
     *      details.
     */
    //System.abortFxn = System.abortStd;
    System.abortFxn = System.abortSpin;
    //System.abortFxn = "&myAbortSystem";
    
    /* Enable System_printf() to display floats. */
    System.extendedFormats = '%f%$S';
    
    /*
     * The Exit handler is called when the system exits normally.
     *
     * Pick one:
     *  - System.exitStd (default)
     *      Call the ANSI C Standard 'exit()' to terminate the application.
     *  - System.exitSpin
     *      A lightweight exit function that loops indefinitely in a while(1) trap
     *      function.
     *  - A custom exit function
     *      A user-defined function. See the System module documentation for
     *      details.
     */
    //System.exitFxn = System.exitStd;
    System.exitFxn = System.exitSpin;
    //System.exitFxn = "&myExitSystem";
    
    /*
     * Minimize exit handler array in the System module. The System module includes
     * an array of functions that are registered with System_atexit() which is
     * called by System_exit(). The default value is 8.
     */
    System.maxAtexitHandlers = 0;
    
    /*
     * The System.SupportProxy defines a low-level implementation of System
     * functions such as System_printf(), System_flush(), etc.
     *
     * Pick one pair:
     *  - SysMin
     *      This module maintains an internal configurable circular buffer that
     *      stores the output until System_flush() is called.
     *      The size of the circular buffer is set via SysMin.bufSize.
     *  - SysCallback
     *      SysCallback allows for user-defined implementations for System APIs.
     *      The SysCallback support proxy has a smaller code footprint and can be
     *      used to supply custom System_printf services.
     *      The default SysCallback functions point to stub functions. See the
     *      SysCallback module's documentation.
     */
    //var SysMin = xdc.useModule('xdc.runtime.SysMin');
    //SysMin.bufSize = 128;
    //System.SupportProxy = SysMin;
    var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
    System.SupportProxy = SysCallback;
    //SysCallback.abortFxn = "&myUserAbort";
    //SysCallback.exitFxn  = "&myUserExit";
    //SysCallback.flushFxn = "&myUserFlush";
    //SysCallback.putchFxn = "&myUserPutch";
    //SysCallback.readyFxn = "&myUserReady";
    
    
    
    /* ================ Task configuration ================ */
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    /*
     * Check task stacks for overflow conditions.
     *
     * Pick one:
     *  - true (default)
     *      Enables runtime checks for task stack overflow conditions during
     *      context switching ("from" and "to")
     *  - false
     *      Disables runtime checks for task stack overflow conditions.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Task.checkStackFlag = true;
    Task.checkStackFlag = false;
    
    /*
     * Set the default task stack size when creating tasks.
     *
     * The default is dependent on the device being used. Reducing the default stack
     * size yields greater memory savings.
     */
    Task.defaultStackSize = 1024;
    
    /*
     * Enables the idle task.
     *
     * Pick one:
     *  - true (default)
     *      Creates a task with priority of 0 which calls idle hook functions. This
     *      option must be set to true to gain power savings provided by the Power
     *      module.
     *  - false
     *      No idle task is created. This option consumes less memory as no
     *      additional default task stack is needed.
     *      To gain power savings by the Power module without having the idle task,
     *      add Idle.run as the Task.allBlockedFunc.
     */
    Task.enableIdleTask = false;
    //Task.enableIdleTask = false;
    //Task.allBlockedFunc = Idle.run;
    
    /*
     * If Task.enableIdleTask is set to true, this option sets the idle task's
     * stack size.
     *
     * Reducing the idle stack size yields greater memory savings.
     */
    Task.idleTaskStackSize = 512;
    
    /*
     * Reduce the number of task priorities.
     * The default is 16.
     * Decreasing the number of task priorities yield memory savings.
     */
    Task.numPriorities = 16;
    
    
    
    /* ================ Types configuration ================ */
    var Types = xdc.useModule('xdc.runtime.Types');
    /*
     * This module defines basic constants and types used throughout the
     * xdc.runtime package.
     */
    
    
    
    /* ================ TI-RTOS middleware configuration ================ */
    var mwConfig = xdc.useModule('ti.mw.Config');
    /*
     * Include TI-RTOS middleware libraries
     */
    
    
    
    /* ================ TI-RTOS drivers' configuration ================ */
    var driversConfig = xdc.useModule('ti.drivers.Config');
    /*
     * Include TI-RTOS drivers
     *
     * Pick one:
     *  - driversConfig.LibType_NonInstrumented (default)
     *      Use TI-RTOS drivers library optimized for footprint and performance
     *      without asserts or logs.
     *  - driversConfig.LibType_Instrumented
     *      Use TI-RTOS drivers library for debugging with asserts and logs enabled.
     */
    driversConfig.libType = driversConfig.LibType_NonInstrumented;
    Hwi.dispatcherSwiSupport = true;
    Hwi.dispatcherAutoNestingSupport = true;
    Hwi.checkStackFlag = true;
    Hwi.dispatcherIrpTrackingSupport = true;
    Clock.tickSource = Clock.TickSource_TIMER;
    Clock.tickPeriod = 10;
    var heapMem0Params = new HeapMem.Params();
    heapMem0Params.instance.name = "heapMem0";
    Program.global.heapMem0 = HeapMem.create(heapMem0Params);/*
     * Copyright (c) 2015-2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * 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.
     */
    
    
    
    /* ================ Boot configuration ================ */
    var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
    var Timer = xdc.useModule('ti.sysbios.hal.Timer');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    
    
    
    /* ================ Defaults (module) configuration ================ */
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    var HwiCommon = xdc.useModule('ti.sysbios.family.arm.HwiCommon');
    var Text = xdc.useModule('xdc.runtime.Text');
    var GateTask = xdc.useModule('ti.sysbios.gates.GateTask');
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    /*
     * A flag to allow module names to be loaded on the target. Module name
     * strings are placed in the .const section for debugging purposes.
     *
     * Pick one:
     *  - true (default)
     *      Setting this parameter to true will include name strings in the .const
     *      section so that Errors and Asserts are easier to debug.
     *  - false
     *      Setting this parameter to false will reduce footprint in the .const
     *      section. As a result, Error and Assert messages will contain an
     *      "unknown module" prefix instead of the actual module name.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Defaults.common$.namedModule = true;
    Defaults.common$.namedModule = false;
    
    
    
    /* ================ Error configuration ================ */
    var Error = xdc.useModule('xdc.runtime.Error');
    /*
     * This function is called to handle all raised errors, but unlike
     * Error.raiseHook, this function is responsible for completely handling the
     * error with an appropriately initialized Error_Block.
     *
     * Pick one:
     *  - Error.policyDefault (default)
     *      Calls Error.raiseHook with an initialized Error_Block structure and logs
     *      the error using the module's logger.
     *  - Error.policySpin
     *      Simple alternative that traps on a while(1) loop for minimized target
     *      footprint.
     *      Using Error.policySpin, the Error.raiseHook will NOT called.
     */
    //Error.policyFxn = Error.policyDefault;
    Error.policyFxn = Error.policySpin;
    
    /*
     * If Error.policyFxn is set to Error.policyDefault, this function is called
     * whenever an error is raised by the Error module.
     *
     * Pick one:
     *  - Error.print (default)
     *      Errors are formatted and output via System_printf() for easier
     *      debugging.
     *  - null
     *      Errors are not formatted or logged. This option reduces code footprint.
     *  - non-null function
     *      Errors invoke custom user function. See the Error module documentation
     *      for more details.
     */
    //Error.raiseHook = Error.print;
    Error.raiseHook = null;
    //Error.raiseHook = "&myErrorFxn";
    
    /*
     * If Error.policyFxn is set to Error.policyDefault, this option applies to the
     * maximum number of times the Error.raiseHook function can be recursively
     * invoked. This option limits the possibility of an infinite recursion that
     * could lead to a stack overflow.
     * The default value is 16.
     */
    Error.maxDepth = 2;
    /*
     * The Idle module is used to specify a list of functions to be called when no
     * other tasks are running in the system.
     *
     * Functions added here will be run continuously within the idle task.
     *
     * Function signature:
     *     Void func(Void);
     */
    //Idle.addFunc("&myIdleFunc");
    
    
    
    /* ================ Kernel (SYS/BIOS) configuration ================ */
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    /*
     * Enable asserts in the BIOS library.
     *
     * Pick one:
     *  - true (default)
     *      Enables asserts for debugging purposes.
     *  - false
     *      Disables asserts for a reduced code footprint and better performance.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //BIOS.assertsEnabled = true;
    BIOS.assertsEnabled = null;
    
    /*
     * Specify default heap size for BIOS.
     */
    BIOS.heapSize =4096; //10000; //4096; //1024;
    
    /*
     * Specify default CPU Frequency.
     */
    BIOS.cpuFreq.lo = 48000000;
    
    /*
     * A flag to determine if xdc.runtime sources are to be included in a custom
     * built BIOS library.
     *
     * Pick one:
     *  - false (default)
     *      The pre-built xdc.runtime library is provided by the respective target
     *      used to build the application.
     *  - true
     *      xdc.runtime library sources are to be included in the custom BIOS
     *      library. This option yields the most efficient library in both code
     *      footprint and runtime performance.
     */
    //BIOS.includeXdcRuntime = false;
    BIOS.includeXdcRuntime = true;
    
    /*
     * The SYS/BIOS runtime is provided in the form of a library that is linked
     * with the application. Several forms of this library are provided with the
     * SYS/BIOS product.
     *
     * Pick one:
     *   - BIOS.LibType_Custom
     *      Custom built library that is highly optimized for code footprint and
     *      runtime performance.
     *   - BIOS.LibType_Debug
     *      Custom built library that is non-optimized that can be used to
     *      single-step through APIs with a debugger.
     *
     */
    BIOS.libType = BIOS.LibType_Instrumented;
    //BIOS.libType = BIOS.LibType_Debug;
    
    /*
     * Runtime instance creation enable flag.
     *
     * Pick one:
     *   - true (default)
     *      Allows Mod_create() and Mod_delete() to be called at runtime which
     *      requires a default heap for dynamic memory allocation.
     *   - false
     *      Reduces code footprint by disallowing Mod_create() and Mod_delete() to
     *      be called at runtime. Object instances are constructed via
     *      Mod_construct() and destructed via Mod_destruct().
     *
     *  When using BIOS in ROM:
     *      This option must be set to true.
     */
    BIOS.runtimeCreatesEnabled = true;
    //BIOS.runtimeCreatesEnabled = false;
    
    /*
     * Enable logs in the BIOS library.
     *
     * Pick one:
     *  - true (default)
     *      Enables logs for debugging purposes.
     *  - false
     *      Disables logging for reduced code footprint and improved runtime
     *      performance.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //BIOS.logsEnabled = true;
    BIOS.logsEnabled = null;
    
    
    
    /* ================ Memory configuration ================ */
    var Memory = xdc.useModule('xdc.runtime.Memory');
    /*
     * The Memory module itself simply provides a common interface for any
     * variety of system and application specific memory management policies
     * implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
     */
    
    
    
    /* ================ Program configuration ================ */
    /*
     *  Program.stack is ignored with IAR. Use the project options in
     *  IAR Embedded Workbench to alter the system stack size.
     */
    if (!Program.build.target.$name.match(/iar/)) {
        /*
         *  Reducing the system stack size (used by ISRs and Swis) to reduce
         *  RAM usage.
         */
        Program.stack = 768;
    }
    
    
    
    /*
     * Uncomment to enable Semihosting for GNU targets to print to the CCS console.
     * Please read the following TIRTOS Wiki page for more information on Semihosting:
     * processors.wiki.ti.com/.../TI-RTOS_Examples_SemiHosting
     */
    
    if (Program.build.target.$name.match(/gnu/)) {
        //var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
    }
    
    /* ================ ROM configuration ================ */
    /*
     * To use BIOS in flash, comment out the code block below.
     */
     /*
    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    if (Program.cpu.deviceName.match(/CC26/)) {
        ROM.romName = ROM.CC2650;
    }
    else if (Program.cpu.deviceName.match(/CC13/)) {
        ROM.romName = ROM.CC1350;
    }*/
    
    
    
    /* ================ Semaphore configuration ================ */
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    /*
     * Enables global support for Task priority pend queuing.
     *
     * Pick one:
     *  - true (default)
     *      This allows pending tasks to be serviced based on their task priority.
     *  - false
     *      Pending tasks are services based on first in, first out basis.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Semaphore.supportsPriority = true;
    Semaphore.supportsPriority = false;
    
    /*
     * Allows for the implicit posting of events through the semaphore,
     * disable for additional code saving.
     *
     * Pick one:
     *  - true
     *      This allows the Semaphore module to post semaphores and events
     *      simultaneously.
     *  - false (default)
     *      Events must be explicitly posted to unblock tasks.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Semaphore.supportsEvents = true;
    Semaphore.supportsEvents = false;
    
    
    /* ================ Event configuration ================ */
    var Event = xdc.useModule('ti.sysbios.knl.Event');
    
    
    /* ================ Swi configuration ================ */
    var Swi = xdc.useModule('ti.sysbios.knl.Swi');
    /*
     * A software interrupt is an object that encapsulates a function to be
     * executed and a priority. Software interrupts are prioritized, preempt tasks
     * and are preempted by hardware interrupt service routines.
     *
     * This module is included to allow Swi's in a users' application.
     */
    
    /*
     * Reduce the number of swi priorities from the default of 16.
     * Decreasing the number of swi priorities yields memory savings.
     */
    Swi.numPriorities = 6;
    
    
    
    /* ================ System configuration ================ */
    var System = xdc.useModule('xdc.runtime.System');
    /*
     * The Abort handler is called when the system exits abnormally.
     *
     * Pick one:
     *  - System.abortStd (default)
     *      Call the ANSI C Standard 'abort()' to terminate the application.
     *  - System.abortSpin
     *      A lightweight abort function that loops indefinitely in a while(1) trap
     *      function.
     *  - A custom abort handler
     *      A user-defined function. See the System module documentation for
     *      details.
     */
    //System.abortFxn = System.abortStd;
    System.abortFxn = System.abortSpin;
    //System.abortFxn = "&myAbortSystem";
    
    /* Enable System_printf() to display floats. */
    System.extendedFormats = '%f%$S';
    
    /*
     * The Exit handler is called when the system exits normally.
     *
     * Pick one:
     *  - System.exitStd (default)
     *      Call the ANSI C Standard 'exit()' to terminate the application.
     *  - System.exitSpin
     *      A lightweight exit function that loops indefinitely in a while(1) trap
     *      function.
     *  - A custom exit function
     *      A user-defined function. See the System module documentation for
     *      details.
     */
    //System.exitFxn = System.exitStd;
    System.exitFxn = System.exitSpin;
    //System.exitFxn = "&myExitSystem";
    
    /*
     * Minimize exit handler array in the System module. The System module includes
     * an array of functions that are registered with System_atexit() which is
     * called by System_exit(). The default value is 8.
     */
    System.maxAtexitHandlers = 0;
    
    /*
     * The System.SupportProxy defines a low-level implementation of System
     * functions such as System_printf(), System_flush(), etc.
     *
     * Pick one pair:
     *  - SysMin
     *      This module maintains an internal configurable circular buffer that
     *      stores the output until System_flush() is called.
     *      The size of the circular buffer is set via SysMin.bufSize.
     *  - SysCallback
     *      SysCallback allows for user-defined implementations for System APIs.
     *      The SysCallback support proxy has a smaller code footprint and can be
     *      used to supply custom System_printf services.
     *      The default SysCallback functions point to stub functions. See the
     *      SysCallback module's documentation.
     */
    //var SysMin = xdc.useModule('xdc.runtime.SysMin');
    //SysMin.bufSize = 128;
    //System.SupportProxy = SysMin;
    var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
    System.SupportProxy = SysCallback;
    //SysCallback.abortFxn = "&myUserAbort";
    //SysCallback.exitFxn  = "&myUserExit";
    //SysCallback.flushFxn = "&myUserFlush";
    //SysCallback.putchFxn = "&myUserPutch";
    //SysCallback.readyFxn = "&myUserReady";
    
    
    
    /* ================ Task configuration ================ */
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    /*
     * Check task stacks for overflow conditions.
     *
     * Pick one:
     *  - true (default)
     *      Enables runtime checks for task stack overflow conditions during
     *      context switching ("from" and "to")
     *  - false
     *      Disables runtime checks for task stack overflow conditions.
     *
     *  When using BIOS in ROM:
     *      This option must be set to false.
     */
    //Task.checkStackFlag = true;
    Task.checkStackFlag = false;
    
    /*
     * Set the default task stack size when creating tasks.
     *
     * The default is dependent on the device being used. Reducing the default stack
     * size yields greater memory savings.
     */
    Task.defaultStackSize = 1024;
    
    /*
     * Enables the idle task.
     *
     * Pick one:
     *  - true (default)
     *      Creates a task with priority of 0 which calls idle hook functions. This
     *      option must be set to true to gain power savings provided by the Power
     *      module.
     *  - false
     *      No idle task is created. This option consumes less memory as no
     *      additional default task stack is needed.
     *      To gain power savings by the Power module without having the idle task,
     *      add Idle.run as the Task.allBlockedFunc.
     */
    Task.enableIdleTask = false;
    //Task.enableIdleTask = false;
    //Task.allBlockedFunc = Idle.run;
    
    /*
     * If Task.enableIdleTask is set to true, this option sets the idle task's
     * stack size.
     *
     * Reducing the idle stack size yields greater memory savings.
     */
    Task.idleTaskStackSize = 512;
    
    /*
     * Reduce the number of task priorities.
     * The default is 16.
     * Decreasing the number of task priorities yield memory savings.
     */
    Task.numPriorities = 16;
    
    
    
    /* ================ Types configuration ================ */
    var Types = xdc.useModule('xdc.runtime.Types');
    /*
     * This module defines basic constants and types used throughout the
     * xdc.runtime package.
     */
    
    
    
    /* ================ TI-RTOS middleware configuration ================ */
    var mwConfig = xdc.useModule('ti.mw.Config');
    /*
     * Include TI-RTOS middleware libraries
     */
    
    
    
    /* ================ TI-RTOS drivers' configuration ================ */
    var driversConfig = xdc.useModule('ti.drivers.Config');
    /*
     * Include TI-RTOS drivers
     *
     * Pick one:
     *  - driversConfig.LibType_NonInstrumented (default)
     *      Use TI-RTOS drivers library optimized for footprint and performance
     *      without asserts or logs.
     *  - driversConfig.LibType_Instrumented
     *      Use TI-RTOS drivers library for debugging with asserts and logs enabled.
     */
    driversConfig.libType = driversConfig.LibType_NonInstrumented;
    Hwi.dispatcherSwiSupport = true;
    Hwi.dispatcherAutoNestingSupport = true;
    Hwi.checkStackFlag = true;
    Hwi.dispatcherIrpTrackingSupport = true;
    Clock.tickSource = Clock.TickSource_TIMER;
    Clock.tickPeriod = 10;

  • PL,
    Thank you for sending the .cfg file.
    Yes, that may be what is going on.  I expect you’ll always see a bit of jitter if there are other interrupts firing.  But +/-30usec is pretty significant.  
    The RTC timer that the Clock module uses runs at 32768Hz.  So the actual interrupt resolution from the RTC is 30.5 usec.  When you use Task_sleep(), that API creates timeouts via the Clock module, which uses the RTC underneath.   So if your timing is based on the RTC, that amount of jitter seems reasonable.  
    But if your Timer instance is using SysTick (I think that is the case because of “var Timer = xdc.useModule('ti.sysbios.hal.Timer');” in the .cfg file), then the interrupt resolutionsis at the CPU rate.
    Can you please post the code you are using to create and program up your Timer instance?
    Thanks,
    Scott
  • Hi Scott,

    Thank you for the support.

    please see the code below.

    regards

    PL

    #include <ti/sysbios/hal/Timer.h>
    
     Timer_Params timer0Params;
    
        Timer_Params_init(&timer0Params);
        timer0Params.periodType=Timer_PeriodType_COUNTS;
        timer0Params.runMode=Timer_RunMode_CONTINUOUS;
        timer0Params.startMode=Timer_StartMode_AUTO;
    
    
        uint32_t nominalPeriod=0;
        nominalPeriod=480000/10;    // 1khz
        timer0Params.period=nominalPeriod;
    
        timer0Hdl = Timer_create(Timer_ANY, fooFxn, &timer0Params, NULL);

  • Hi PL,

    Thank you for posting the code.  

    This timer creation code looks right to me,to set up a 1KHz periodic rate from the SysTick timer running at 48MHz with the CPU.

    I looked again at the .cfg code you posted and see that it seems to be a combination of two separate .cfg files.  Is this correct, or was there maybe an issue of posting the content to the forum(?)    For example, I see two instances of “var Timer = xdc.useModule('ti.sysbios.hal.Timer');”.  This particular repetition isn’t a “problem”, but it makes me wonder if there are maybe some other conflicts with the combination of .cfg files that might not be intended?

    Regards,
    Scott

  • Hi Scott.

    My error, it was a double paste on the post, I checked my .cfg and there is no repetition at all.

    May you try to reproduce the issue?

    thank you

    PL
  • Hi PL,

    Sorry for the delay, I’ve been focused on a new product release.

    I know Alan helped you with setting up a zero latency interrupt using an lm4.Timer (on this thread: e2e.ti.com/.../2333724

    Did that resolve the jitter issue for you?

    Thanks,
    Scott

  • Hi Scott,

    Using a zero latency interrupt the jitter is negligible as one would expect. The issue however is that within a zero latency ISR i can not call BIOS api as I would do.
    For this reason i can only say the problem is partially resolved.

    regards
    PL