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.

SYS/BIOS periodic task work just one time

Hello.

I have a Spectrum Digital 816x/389x EVM board with DM8168 processor.
My software is CCS 5.5.0.00077 with SYS/BIOS 6.35.4.50 and XDCTools 3.25.3.72.

I am trying to run a SYS/BIOS "TI Typical Example". It's code here:

#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/*
 *  ======== taskFxn ========
 */
Void taskFxn(UArg a0, UArg a1);


/*
 *  ======== main ========
 */
Int main()
{
    Task_Handle task;
    Error_Block eb;

    System_printf("SYS:enter main()\n");

    Error_init(&eb);
    task = Task_create(taskFxn, NULL, &eb);
    if (task == NULL) {
        System_printf("SYS:Task_create() failed!\n");
        BIOS_exit(0);
    }

    BIOS_start();    /* does not return */
    return(0);
}

/*
 *  ======== Implementation ========
 */
Void taskFxn(UArg a0, UArg a1)
{
    System_printf("SYS:enter taskFxn()\n");

    Task_sleep(10);

    System_printf("SYS:exit taskFxn()\n");
}

The problem is that the taskFxn is triggered only once, and then passes control to idle task permanently.
I figured that the task will display "enter-exit" at an interval of 10 ms.
I am sure that I did not notice some small detail. I would be grateful for your help to find it.

My SYS/BIOS .cfg file:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
var Cache = xdc.useModule('ti.sysbios.family.arm.a8.Cache');
var Mmu = xdc.useModule('ti.sysbios.family.arm.a8.Mmu');
var ti_sysbios_family_arm_a8_intcps_Hwi = xdc.useModule('ti.sysbios.family.arm.a8.intcps.Hwi');
var TimestampProvider = xdc.useModule('ti.sysbios.family.arm.a8.TimestampProvider');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var ti_sysbios_hal_Timer = xdc.useModule('ti.sysbios.hal.Timer');
var Startup = xdc.useModule('xdc.runtime.Startup');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');

/* 
 * Program.argSize sets the size of the .args section. 
 * The examples don't use command line args so argSize is set to 0.
 */
Program.argSize = 0x0;

/*
 * Uncomment this line to globally disable Asserts.
 * All modules inherit the default from the 'Defaults' module.  You
 * can override these defaults on a per-module basis using Module.common$. 
 * Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
 */

/*
 * Uncomment this line to keep module names from being loaded on the target.
 * The module name strings are placed in the .const section. Setting this
 * parameter to false will save space in the .const section.  Error and
 * Assert messages will contain an "unknown module" prefix instead
 * of the actual module name.
Defaults.common$.namedModule = false;
 */

/*
 * Minimize exit handler array in System.  The System module includes
 * an array of functions that are registered with System_atexit() to be
 * called by System_exit().
 */
System.maxAtexitHandlers = 4;       

/* 
 * Uncomment this line to disable the Error print function.  
 * We lose error information when this is disabled since the errors are
 * not printed.  Disabling the raiseHook will save some code space if
 * your app is not using System_printf() since the Error_print() function
 * calls System_printf().
Error.raiseHook = null;
 */

/* 
 * Uncomment this line to keep Error, Assert, and Log strings from being
 * loaded on the target.  These strings are placed in the .const section.
 * Setting this parameter to false will save space in the .const section.
 * Error, Assert and Log message will print raw ids and args instead of
 * a formatted message.
Text.isLoaded = false;
 */

/*
 * Uncomment this line to disable the output of characters by SysMin
 * when the program exits.  SysMin writes characters to a circular buffer.
 * This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
 */

/* 
 * The BIOS module will create the default heap for the system.
 * Specify the size of this default heap.
 */
BIOS.heapSize = 0x2000;

/*
 * Build a custom SYS/BIOS library from sources.
 */
BIOS.libType = BIOS.LibType_Custom;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x1000;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x400;

/* 
 * Create and install logger for the whole system
 */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 32;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

/*
System.SupportProxy = SysMin;
*/
System.SupportProxy = SysStd;

Timer.checkFrequency = true;

  • I think you have a misunderstanding of the role of the taskFxn(). If you exit this function your task is done...

    Calling a function periodically can be done from a Sys/Bios timer. However a task can run forever (as long as you don't end it) but may still be pre-empted any time. So you can do a

    while(1)
    {
        .. do something
       Task_yield(x);   // or sleep()
    }

    for example. Just look at some of the Sys/Bios examples.

    Regards,

  • Hi Frank!

    Thank you for a quick responce!

    It worked.

    I am not new in RTOSystems (I worked with RTX and uC/OS), but I was baffled by this example. 

    Best regards