I'm working with a Nucleo-STm32F767 and I had generated the code with CubeMX including FreeRTOS 9.

My code has 5 task and each task has a loop, where the task is suspended on each iteration.

  while( 1 )
  {   
    //Do something

    osDelay(TASK_MAIN_DELAY_MS);
  }

At this point my system works well.

Now I added a task that handle the communication with an SPI network controller. The network controller has it own middleware written in C.

Now every time I try to suspend a task (with osDelay) my code is stucked into prvCheckTasksWaitingTermination and my system is blocked forever.

static void prvCheckTasksWaitingTermination( void )
{

    /** THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK **/

    #if ( INCLUDE_vTaskDelete == 1 )
    {
        BaseType_t xListIsEmpty;

        /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
        too often in the idle task. */
        while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U )
        {
            vTaskSuspendAll();
            {
                xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );
            }
            ( void ) xTaskResumeAll();

            if( xListIsEmpty == pdFALSE )
            {
                TCB_t *pxTCB;

                taskENTER_CRITICAL();
                {
                    pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
                    ( void ) uxListRemove( &( pxTCB->xStateListItem ) );
                    --uxCurrentNumberOfTasks;
                    --uxDeletedTasksWaitingCleanUp;
                }
                taskEXIT_CRITICAL();

                prvDeleteTCB( pxTCB );
            }
            else
            {
                mtCOVERAGE_TEST_MARKER();
            }
        }
    }
    #endif /* INCLUDE_vTaskDelete */

In particular, the execution is stopped here: while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U ) becuase uxDeletedTasksWaitingCleanUp is equal to 0.

I don't know how to resolve this issue :(

Anybody can help me?

Thanks and best regards, Federico

1 Answers

0
Richard On

prvCheckTaskWaitingTermination is just part of the idle task. Unless you are running tickless operation it will just keep executing as long as no higher priority tasks are able to run. In your case I'm going to guess that the SPI driver is doing something that stops or masks the tick interrupt so time doesn't change, so delays never end. Just a guess though.