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.

RTOS/MSP432P4111: SysBIOS Semaphore_pend times out (or hangs if I BIOS_WAIT_FOREVER), when Seamphore count == 1

Part Number: MSP432P4111

Tool/software: TI-RTOS

I have this piece of code here, where the Semaphore_pend is not behaving properly.

uint32 tPost, tPendEnter, tPendExit;
/*******************************************************************************
  Callback to notify a transaction has been completed on channel 1
*******************************************************************************/
static void NotifyComplete(void)
{
   Semaphore_post(hSemDpotComp);
   tPost = Clock_getTicks();
}

/*******************************************************************************
  Wait for a Transaction to complete on channel 1
*******************************************************************************/
static BOOL WaitForComplete(uint32 timeout)
{
   uint32 timeInc = 10, timeVal = 0;
   BOOL success = FALSE;
   tPendEnter = Clock_getTicks();
#if 1 // THIS Case always fails
   success = (BOOL)Semaphore_pend(hSemDpotComp, timeout);
#else // This Case always works the first time through
   while( timeVal < timeout )
   {
      success = (BOOL)Semaphore_pend(hSemDpotComp, timeInc);
      timeVal += timeInc;
      if( success )
         break;
   }
#endif
   tPendExit = Clock_getTicks();
   return success;
}

You see in the #if 1 section the semaphore always times out, even though it shouldn't.  I've edited the timeout value to be BIOS_WAIT_FOREVER, and paused execution, and verified that the Semaphore hSemDpotComp (Binary Semaphore in XDC config file) is 1, aka available.  However the pend has not, and never returns.

If I change #if 1 to #if 0, and use the while loop.  The Semaphore_pend is successful every time.  It never times out.  Also based on the clock ticks, the pend occurs at the same Clock_getTicks() time value as the post.  the pend is successful after the first iteration every time (timeVal always = timeInc).  usually tPendExit is 1 tick after tPendEnter and tPendPost.

Notes:

  1. void NotifyComplete() is a callback function that the HWI call's to post the semaphore.  
  2. The HWI is a standard interrupt, it is NOT zero latency, therefore this OS call should be permitted
  3. The pend in WaitForComplete() is called from a Task context.  
  4. Points 1-3 all appear to be an acceptable way to handle this 
  5. I have optimization turned off right now

Here's a capture of the ROV when the heartBeat task is clearly not recognizing the Semaphore is available.  Note the Semaphore Count is showing 1, while the status clearly show's the heartBeat task is waiting for the semaphore.

Why is SysBIOS not exiting the pend when the semaphore is clearly available (per ROV)?

As I state above...by changing my #if 1 to #if 0 and using the the loop, the pend works on the first iteration, every single time.  

**Attention** This is a public forum