Binary Semaphore runs on task initialising

Hi, I have created a binary semaphore in my module initialization code: vSemaphoreCreateBinary( xBinarySemaphoreRxMsg ); It initializes ok,  I then create a new task to run: xTaskCreate( vRX_MsgHandlerTask, "RX", MSG_TASK_STACK_SIZE, NULL, xTask_Priority, NULL ); All ok, here is the basic task code: void  vRX_MsgHandlerTask( void *pvParameters ) {     unsigned portSHORT i;     //unsigned portSHORT usFrameIndex;     ulMsgCounter = 0;         for( ;; )     {         //blocking for RX event to happen         xSemaphoreTake( xBinarySemaphoreRxMsg , portMAX_DELAY );         TRACE_sprintf("Processing the Datarn");         } } Now when the vRX_MsgHandlerTask starts for the first time the TRACE_sprintf("Processing the Datarn"); is called and outputs to the console. I am pretty sure there has been no call to xSemaphoreGive( xBinarySemaphoreRxMsg  ); it is as if the binary semaphore thinks it can take the semaphore, the code runs as expected after this has happened. Is this a school boy error, hope you can help. Phil

Binary Semaphore runs on task initialising

The semaphore starts out available to be taken (check out the definition of "vSemaphoreCreateBinary" in "semphr.h").  You must take it first outside of your task’s loop if you don’t want it to be available when your loop first runs.

Binary Semaphore runs on task initialising

Thanks for the quick response that fixed the problem. :) Phil