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.

initial semaphore count

Other Parts Discussed in Thread: SYSBIOS

Hi

I have a problem with the initial count value of my semaphores

I have created 5 semaphores 4 binary and one counting all with initial count value 0, but when I start my program the semaphores shown in RTOS Object View (ROV) does not match my configuration, which causes my program to crash.

The screendump below shows the declaration of the semaphores and the ROV debug window

The complete configuration is pasted below

xdc.loadPackage('ti.bios.tconf');
var SEM = xdc.useModule('ti.bios.SEM');
var CLK = xdc.useModule('ti.bios.CLK');
var TSK = xdc.useModule('ti.bios.TSK');
var LOG = xdc.useModule('ti.bios.LOG');
var PRD = xdc.useModule('ti.bios.PRD');
var QUE = xdc.useModule('ti.bios.QUE');
var STS = xdc.useModule('ti.bios.STS');
var MBX = xdc.useModule('ti.bios.MBX');
var SWI = xdc.useModule('ti.bios.SWI');
var MEM = xdc.useModule('ti.bios.MEM');

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 ti_sysbios_family_c64p_EventCombiner = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var ti_sysbios_family_c66_tci66xx_CpIntc = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Intrinsics = xdc.useModule('ti.sysbios.knl.Intrinsics');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
// var Queue = xdc.useModule('ti.sysbios.knl.Queue');
// var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
// var Startup = xdc.useModule('xdc.runtime.Startup');

/* Load the CSL package */
var Csl = xdc.useModule('ti.csl.Settings');
var Startup = xdc.useModule('xdc.runtime.Startup');
var Cache = xdc.useModule('ti.sysbios.hal.Cache');

/* Load the CPPI package */
var Cppi = xdc.loadPackage('ti.drv.cppi');

/* Load the QMSS package */
var Qmss = xdc.loadPackage('ti.drv.qmss');

/* Load the Platform/NDK Transport/EMAC packages */
var PlatformLib = xdc.loadPackage('ti.platform.evmc6657l');
//var NdkTransport = xdc.loadPackage('ti.transport.ndk');
//var EmacLLD = xdc.loadPackage('ti.drv.emac');

/* STATIC configuration.
* Comment this line out if you want to dynamically create instance objects. */
//Defaults.common$.memoryPolicy = xdc.module("xdc.runtime.Types").STATIC_POLICY;


/* Create a Heap */
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
heapMemParams.size = 0x30000;
heapMemParams.sectionName = "systemHeap";
heapMemParams.instance.name = "DDR3handle";
Program.global.DDR3handle = HeapMem.create(heapMemParams);
MEM.addHeapMem(Program.global.DD3handle, "DDR3");

/* (Alternative?) Create a heap using ti.bios.HeapBuf.
var heapBufParams = new HeapBuf.Params;
heapBufParams.numBlocks = 8;
heapBufParams.blockSize = 32;
heapBufParams.align = 32;
Program.global.heap0 = HeapBuf.create(heapBufParams);
Memory.defaultHeapInstance = Program.global.heap0;
*/

/* This is the default memory heap. */
Memory.defaultHeapInstance = Program.global.DDR3handle;
Program.sectMap["emacComm"] = "DDR3";
Program.sectMap["systemHeap"] = "DDR3";
Program.sectMap[".switch"] = "L2SRAM";
Program.sectMap[".sysmem"] = "L2SRAM";
Program.sectMap[".args"] = "L2SRAM";
Program.sectMap[".cio"] = "L2SRAM";
Program.sectMap[".far"] = "DDR3";
Program.sectMap[".cinit"] = "L2SRAM";
Program.sectMap[".bss"] = "L2SRAM";
Program.sectMap[".rodata"] = "L2SRAM";
Program.sectMap[".neardata"] = "L2SRAM";
Program.sectMap[".const"] = "DDR3";
Program.sectMap[".text"] = "DDR3";
Program.sectMap[".code"] = "DDR3";
Program.sectMap[".data"] = "DDR3";
Program.sectMap["platform_lib"] = "DDR3";
Program.sectMap[".far:taskStackSection"] = "L2SRAM";
Program.sectMap[".stack"] = "L2SRAM";
Program.sectMap[".far:IMAGEDATA"] = {loadSegment: "L2SRAM", loadAlign: 8};

/* Required if using System_printf to output on the console */
/* Configure SysMin for System_printfs because SysStd cannot be used when
* calling System_printf from Hwis and Swis. */
// SysStd = xdc.useModule('xdc.runtime.SysStd');
// System.SupportProxy = SysStd;
System.SupportProxy = SysMin;

/* 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 = 8;

/* 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;
*/


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

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

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

/* Create and install logger for the whole system */
Main.common$.diags_USER1 = Diags.RUNTIME_ON;
Main.common$.diags_USER2 = Diags.RUNTIME_ON;
Main.common$.diags_USER3 = Diags.RUNTIME_ON;
Main.common$.diags_USER4 = Diags.RUNTIME_ON;
Main.common$.diags_USER5 = Diags.RUNTIME_ON;
Main.common$.diags_USER6 = Diags.RUNTIME_ON;
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
loggerBufParams.bufType = LoggerBuf.BufType_CIRCULAR;
loggerBufParams.instance.name = "trace";
loggerBufParams.bufHeap = Program.global.DDR3handle;
Program.global.trace = LoggerBuf.create(loggerBufParams);
Main.common$.logger = Program.global.loggerBuf0;

/* (Optional?)Using the Clock Module */
/* C-usage: UInt32 Clock_getTicks(); */
Clock.tickMode = Clock.TickMode_PERIODIC;
Clock.swiPriority = 15;
Clock.tickPeriod = 1000;


/* (Optional?) Create periodic Timers 1-7 */
var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
Timer.anyMask = 254; // Timer 0 is used by CLK for tick, so clear lowest bit

/* Create the SWIs */
Swi.numPriorities = 16;
var swiParams = new Swi.Params;
swiParams.arg0 = 0;
swiParams.arg1 = 1;
swiParams.priority = 10;
swiParams.instance.name = "SwiRateHigh3";
Program.global.SwiRateHigh1 = Swi.create("&OnSwiRateHigh1", swiParams);
swiParams.priority = 9;
Program.global.SwiRateHigh2 = Swi.create("&OnSwiRateHigh2", swiParams);
swiParams.priority = 5;
Program.global.SwiRateHigh3 = Swi.create("&OnSwiRateHigh3", swiParams);

/* ======== Using the Idle Module ======== */
/* Add idle function to table where idl0Fxn is name of function in C file */
// Idle.addFunc('&idl0Fxn');

/* Create the TASKs */
Task.common$.namedInstance = true;

var task0Params = new Task.Params();
task0Params.instance.name = "Tsk10ms_H";
task0Params.priority = 0x6;
task0Params.stackSection = ".Tsk10msStackSection";
Program.global.Tsk10ms_H = Task.create("&Task10ms", task0Params);
Program.sectMap[".Tsk10msStackSection"] = "L2SRAM";

var task1Params = new Task.Params();
task1Params.instance.name = "Tsk100ms_H";
task1Params.priority = 0x4;
task1Params.stackSection = ".Tsk100msStackSection";
Program.global.Tsk100ms_H = Task.create("&Task100ms", task1Params);
Program.sectMap[".Tsk100msStackSection"] = "L2SRAM";

var task2Params = new Task.Params();
task2Params.instance.name = "Tsk1sec_H";
task2Params.priority = 0x3;
task2Params.stackSection = ".Tsk1secStackSection";
Program.global.Tsk1sec_H = Task.create("&Task1s", task2Params);
Program.sectMap[".Tsk1secStackSection"] = "L2SRAM";

var task3Params = new Task.Params();
task3Params.instance.name = "TskFdspLoad_H";
task3Params.stackSection = ".TskFdspLoadStackSection";
task3Params.stackSize = 0x200;
Program.global.TskFdspLoad_H = Task.create("&CpuLoadTask", task3Params);
Program.sectMap[".TskFdspLoadStackSection"] = "L2SRAM";

/* Create Semaphore Instances as available (count = 1) */
var semaphore1Params = new Semaphore.Params();
semaphore1Params.instance.name = "Sem10msSignal";
semaphore1Params.mode = Semaphore.Mode_BINARY;
Program.global.Sem10msSignal = Semaphore.create(0, semaphore1Params);

var semaphore2Params = new Semaphore.Params();
semaphore2Params.instance.name = "Sem100msSignal";
semaphore2Params.mode = Semaphore.Mode_BINARY;
Program.global.Sem100msSignal = Semaphore.create(0, semaphore2Params);

var semaphore3Params = new Semaphore.Params();
semaphore3Params.instance.name = "Sem1sSignal";
semaphore3Params.mode = Semaphore.Mode_BINARY;
Program.global.Sem1sSignal = Semaphore.create(0, semaphore3Params);

var semaphore4Params = new Semaphore.Params();
semaphore4Params.instance.name = "edma_ping_sem";
semaphore4Params.mode = Semaphore.Mode_BINARY;
Program.global.edma_ping_sem = Semaphore.create(0, semaphore4Params);

var semaphore7Params = new Semaphore.Params();
semaphore7Params.instance.name = "TestSem";
Program.global.TestSem = Semaphore.create(0, semaphore7Params);

/* Create HWIs (Hwi 14,4 taken by ClockTick) */
var hwiParams = new Hwi.Params
hwiParams.arg = 5; // ISR function argument
hwiParams.enableInt = false;// Enable this interrupt when object is created? Default is true = Bool true;
hwiParams.eventId = 6; // Interrupt event ID (Interrupt Selection Number)
hwiParams.maskSetting = Hwi.MaskingOption_SELF;
hwiParams.priority = 6; // Interrupt priority

hwiParams.arg = 0; // ISR function argument
hwiParams.enableInt = false;// Enable this interrupt when object is created? Default is true = Bool true;
hwiParams.eventId = 7; // Interrupt event ID (Interrupt Selection Number)
hwiParams.maskSetting = Hwi.MaskingOption_SELF;
hwiParams.priority = 7; // Interrupt priority
var hwiH_MSG = Hwi.create (7 ,'&MsgFiFoISR',hwiParams); // Create an instance-object(Int intNum, Void(*)(UArg) hwiFxn, params);
hwiH_MSG.eventId = 89;
Program.sectMap[".hs"] = new Program.SectionSpec();
Program.sectMap[".hs"].loadSegment = "L2SRAM";
Program.sectMap[".boot"] = new Program.SectionSpec();
Program.sectMap[".boot"].loadSegment = "L2SRAM";
BIOS.runtimeCreatesEnabled = true;

Can someone see what I am dooing wrong?

Jens

 
  • Can you specify what CCS, SYSBIOS, and XDCTOOLS version you are using?

    Where is your program execution when you took that screenshot?  Please note what it is when you get to main().

    Judah

  • HI

    I am using CCS 5.4.0.00091, SYSBIOS version 6.33.06.50 and XDC version 3.23.04.60

    The screen shot is taken just after calling BIOS_start the first time I want my 10ms task to pend for the semaphore Sem10msSignal 

    When I get to main() the count values for the semaphores are the same. 

    The first semephore I pend for is Sem10msSignal which have a count value of 0

    In the screen dum below I have just stepped over line 49 and I can see in the ROV window that instead of pending on the Sem10msSignal - which should have made the source break at the Task100ms just below - the Semaphore_pend updates the count value on semaphore Sem100Signal (that for some reason was 1) and continues to execute PM_Execute(PM_RepTime_10ms) (line 50)

    Jens

  • Hi

    Something is rotten...

    I tried adding a semaphore_pend(TestSem, SYS_FOREVER) in Task10ms() like this

    void Task10ms()
    {
      while (1)
      {
        PEND_RATE_10MS(); /* Semaphore_pend(Sem10msSignal, SYS_FOREVER) */
        Semaphore_pend(TestSem, SYS_FOREVER);
        PM_Execute(PM_RepTime_10ms);
      }
    }

    Then I recompiled, and Voila! all semaphores were corect and the program seems to run.

    Then I removed the extra Semaphore_pend, recompiled and then the semphore counters are still correct and everything seems to work.

    I have no idea why, but for now it seems that the problem is solved

    Jens

  • Okay, very strange.  I'll considered the problem solved.