This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

osSemaphore problem

The problem is similar to http://www.keil.com/forum/9257/ . I don't know whether it was solved.

when I call osSemaphoreWait(), the returned value is 0xFFFFFFFF (-1) , which is happened when I use hardware timer independently. The code is showing below,

int32_t sem;
osSemaphoreId rl_sem[1];
osSemaphoreDef(sem_0);


//user thread 1
Thread()
{
    rl_sem[0]=osSemaphoreCreate(osSemaphore(sem_0),1);

    while(1)
    {
      ...

      sem = osSemaphoreWait(rl_sem[0],0);

      printf("sem=%d",sem); //sem normally should be 1, but here it is 0xFFFFFFFF, ie, -1
    }
}



//CAN ISR
CAN_IRQHandler()
{
   ...
   osSemaphoreRelease(rl_sem[0]);
}

//timer ISR
Timer_Callback()
{
   // nothing to do with semaphore
}


your advice is much appreciated!