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:
- Loop function with osi_Sleep(1000)
- Starts software timer with callback.
- Timeout Callback closes the connection.
- AWS SDK closes connection using a timer.
- Timer initialization uses osi_Sleep(1).
- 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!