Hi,
I am new to SYS/BIOS and i have few question. I am using CCS 5.3.0.00090,
bios_6_33_06_50,mcsdk_2_01_02_06 , xdctools_3_23_04_60 and C6678 custom board.
I have created two tasks with different priority. I want to use two semaphores(sem0 and sem1) which will use two different clock ticks(myClk0 and myClk1) for Semaphore_post(sem0 and sem1). It does not works.
The problem are as follows:
1. Semaphore 'count' doesnot seem to increment at all. Can you please let me know what's wrong am i doing here ?
2. can I use multiple semaphores for multiple tasks?
The source code is as follows :
/***********Cfg file**************************/
/*Two Semaphores are being created */
var semaphore1Params = new Semaphore.Params();
semaphore1Params.instance.name = "sem1";
Program.global.sem1 = Semaphore.create(null, semaphore1Params);
var semaphore0Params = new Semaphore.Params();
semaphore0Params.instance.name = "sem0";
Program.global.sem0 = Semaphore.create(null, semaphore0Params);
/*the stack size is also being increased*/
BIOS.heapSize = 0x2000;
/* System stack size (used by ISRs and Swis) */
Program.stack = 0x2000;
/* Circular buffer size for System_printf() */
SysMin.bufSize = 4096;
/*******************************************/
/********** main.c ****************/
void hardware_init(void); //customer hardware configuration
void ledTogglegreen (void); //Aplication code
void ledToggleOrange (void); //Aplication code
void hiPriTask (UArg arg0, UArg agr1);
void task (UArg arg0, UArg agr1);
Void clockHandler(UArg arg);
Void clockHandler1(UArg arg);
Clock_Params clockParams;
Clock_Params clock1Params;
Clock_Handle myClk0, myClk1;
/**myIdleFunc**/
Void myIdleFunc()
{
System_printf("Entering myIdleFunc(). \n");
System_exit(0);
}
/*===========main =========*/
Void main()
{
Task_Params taskParams;
Task_Handle myTsk0, myTsk1;
Error_Block eb;
System_printf("Led Blink example Started\n");
Error_init(&eb);
/*Create 1 task with priority 15*/
Task_Params_init(&taskParams);
taskParams.stackSize = 1000;
taskParams.priority = 15; //high priority
myTsk0 = Task_create ((Task_FuncPtr)hiPriTask, &taskParams, &eb);
if (myTsk0 == NULL){
System_abort("hiPriTask create failed");
}
/*create Low priority tasks with priority 1*/
Task_Params_init(&taskParams);
taskParams.priority =1; // low priority task
myTsk1 = Task_create ((Task_FuncPtr)task, &taskParams, &eb);
if (myTsk1 == NULL){
System_abort("LoPriTask create failed");
}
/*Clock tick is being introduced*/
Clock_Params_init(&clockParams);
clockParams.startFlag = TRUE;
clockParams.period = 1000;
myClk0 = Clock_create((Clock_FuncPtr)clockHandler, 1000, &clockParams, &eb);
if(myClk0 == NULL){
System_abort ("Clock create failed");
}
/*Clock tick is being introduced*/
Clock_Params_init(&clock1Params);
clock1Params.startFlag = TRUE;
clock1Params.period = 500;
myClk1 = Clock_create((Clock_FuncPtr)clockHandler1, 500, &clock1Params, &eb);
if(myClk1 == NULL){
System_abort ("Clock2 create failed");
}
/*Initializing customer hardware*/
hardware_init(); //customer hardware
BIOS_start();
}
/*======Clock handler1 ======*/
static void clockHandler1 (UArg arg){
Semaphore_post(sem1);
}
/*======Clock handler ======*/
static void clockHandler (UArg arg){
Semaphore_post(sem0);
}
/*Low priority task*/
Void task(UArg argo, UArg arg1)
{
while(1)
{
/*Semaphore_pend for sem1*/
Semaphore_pend (sem1, BIOS_WAIT_FOREVER);
/*Toggle Led Orange*/
ledToggleOrange(); //application code
}
}
/*High priority task*/
Void hiPriTask(UArg arg0, UArg arg1)
{
while(1)
{
/*Semaphore_pend for Sem0*/
Semaphore_pend (sem0, BIOS_WAIT_FOREVER);
/*Toggle Led Green*/
ledTogglegreen(); //application code
}
}