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/CC3200: System stucks on "Task_allBlockedFunction()"

Part Number: CC3200

Tool/software: TI-RTOS

Hi there,

I'm facing with a problem regarding TI-RTOS in particular with "osi_Sleep" function.

This is my situation:

  • MCU: CC3200
  • TI-RTOS
  • AWS IoT SDK (C)

I use AWS IoT SDK to send and receive data from AWS backend and I implemented an interface layer to permit to IoT SDK the use of SOCKET and TIMER.

Regarding the timer, I built a Timer Software library that uses one hardware timer and create several independent down counter. When a counter reach “0” a callback function is invoked. Every time AWS IoT SDK need to know the time elapsed it uses the time module. Into the initialization of the software timer I put a call to ois_Sleep with 1 millisecond of delay.

 

Everything work until I do this:

Scenario: polling periodically the AWS backend to receive data.

I create a loop that ping the AWS backend and suspend the task for 1 second (osi_Sleep(1000)).

The loop is skipped when:

  • A time out occurs. I initialize another software timer when elapses break the loop.
  • A new message is received.  This event breaks the loop.

 

If the timeout elapses, I invoke a function to close the connection towards the AWS backend and now the system Stuck in this function Task_allBlockedFunction().

/*
 *  ======== Task_enter ========
 *  Here on task's first invocation.
 *
 *  Unlock the Task Scheduler to enter task as though we
 *  returned through Task_restore()
 */
Void Task_enter()
{
    if (Task_module->workFlag) {
        Task_schedule();
    }
    Task_module->locked = FALSE;
    Hwi_enable();
}




Void Task_allBlockedFunction()
{
    volatile UInt delay;

    if (Task_allBlockedFunc == Idle_run) {
        Hwi_enable();
        Idle_run();
        Hwi_disable();
    }
    else if (Task_allBlockedFunc == NULL) {
        Hwi_enable();
        /* Guarantee that interrupts are enabled briefly */
        for (delay = 0; delay < 1; delay++) {
           ;
        }
        Hwi_disable();
    }
    else {
        Task_allBlockedFunc();
        /*
         * disable ints just in case the
         * allBlockedFunc left them enabled
         */
        Hwi_disable();
    }
}

I think that the stuck is related to osi_Sleep function.

This is a recap of operations that system performs:

  1. Loop function with osi_Sleep(1000)
  2. Starts software timer with callback.
  3. Timeout Callback closes the connection.
  4. AWS SDK closes connection using a timer.
  5. Timer initialization uses osi_Sleep(1).
  6. System STUCKS.

May the nested osi_Sleep can create problems?

 

I notice that if I invoke the AWS SDK function (that uses the timer) not in a callback everything works.

 

I can’t figure out to this problem.

Any suggestion?

Thanks!

  • Hi Fede,

    I'm assuming the Timer callback is being called in context of an interrupt.

    1. Are you calling OSI_sleep in the Timer callback? This is not good. OSI_sleep should only be called in a Task.
    2. What function are you using to close the the connection in the Timer callback (step 3 in your list)?
    3. Do you have an Idle task? Easy way to confirm is to look at Tools->ROV->Tasks in CCS (it's available in IAR also).
    4. Do you have power management enabled? I'm assuming no since you are using the debugger (emulation is lost when you go into certain low power modes).

    Todd
  • Hi Todd,
    thanks for the reply.

    My project use TI_RTOS. But I started from an existing project I don't have enough information about the OS config.

    1) Yes put a osi_sleep into the callback. I need to upgrade my timer callback to avoid the use of osi_sleep.

    2) To close the connection I use the function provided by AWS SDK that, for timing, uses my software timer module with a different timer.

    3) My project is based on only one task.

    4) No low power mode enabled. Yes I use the debugger.

    Thanks!