phil4321 wrote on Tuesday, March 31, 2009:
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 Data\r\n");
}
}
Now when the vRX_MsgHandlerTask starts for the first time the TRACE_sprintf("Processing the Data\r\n"); 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