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.

CC2564MODAEM: Questions on BTPS_AddFunctionToScheduler

Part Number: CC2564MODAEM

Hello,

I am using DK TM4C129X and CC2564MODAEM. I have few questions regarding to BTPS_AddFunctionToScheduler. - (I have already read the information provided in BTSKRNL.pdf )

1-If I add a function to scheduler with some Schedule Period, will it call this function at exactly that time with high precision ? If I add a function with 5ms as period, does it execute that function exactly at every 5ms or some tolerance will be there?

2- I noticed that when I add a function with 15ms as period or above, it will execute at that specified interval. But if I add function with below 15ms ( ex- 10ms, 5ms), it will anyway execute once 15ms. Why am I facing this issue ? (The function which I added, had just one variable which increments whenever it is called.)

3- Does all the functions which I add to the BTPS_AddFunctionToScheduler execute simultaneously if I give same time period? For example, if I add two function with 10ms period, will those two functions execute simultaneously as both have the same time period ?

4- Consider this scenario ( my use case )-

if(BTPS_AddFunctionToScheduler(function_1, NULL, 10))
{
         if(BTPS_AddFunctionToScheduler(function_2, NULL, 10))
         {
                  if(BTPS_AddFunctionToScheduler(function_3, NULL, 10))
                   {
                            if(BTPS_AddFunctionToScheduler(function_4, NULL, 30))
                            {
                                         if(BTPS_AddFunctionToScheduler(function_5, NULL, 500))
                                         {
                                                     if(BTPS_AddFunctionToScheduler(function_6 NULL, 10))
                                                     {

                                                                while(1)
                                                                           BTPS_ExecuteScheduler();
                                                       }
                                         }
                           }
                   }
          }
}

How does the above function execute ? My understanding is-  function_1 executes at time t1. It take 10ms to execute. Simultaneously, function_2 executes at  same time t1. It also takes 10ms to execute. Same with function_3 and function_6. These functions are again called at time t1+10ms, t1+20ms and so on... All the functions are executed simultaneously because all are called at 10ms.

4-a - Will all those functions be executing parallelly or one after another?

4-b - And will the system be not doing anything  during those time interval ? ( Because I call the functions only at 10ms. If function finishes executing within 5ms, will the system not do anything for next 5ms ?)

4-c- What will happen if a particular function takes more than 10ms to execute ? Will that execution be halted in midway and start from beginning or will it continue finishing that function execution and starts execution from beginning right away?

4-d- Can you please explain the flow of execution for the above code? ( Meaning, when these functions are executed and at what time? )

Sorry for the big question, but this is really important for my application. It will help me a lot to develop my application, if all my questions are answered.

Regards,

Adhitya

EDIT- 

I have no idea why this got posted in Bluetooth low energy forum. I had chosen Dual Mode Bluetooth Forum.

  • I suggest you to post CC256x related issue to Dual Mode Bluetooth E2E forum at e2e.ti.com/.../
  • Yeah. When creating the thread, I chose Dual Mode Bluetooth Forum. But after posting, I saw that it was in BLE section. That's why I edited my post and mentioned that. I am just waiting to see whether this thread will be moved to the Dual Mode Bluetooth Forum by admins or should I create a new thread again ?
  • Hi,
    Your query has been assigned to relevant engineer. We will get back to you shortly

    Thanks
    Saurabh
  • Ok, thank you.
  • Hello,

    Any update on this ?

    Regards,
    Adhitya
  • I think the response to this is to take a look at how BTPS_ProcessScheduler() works, as all the functions you add to the scheduler are called in this function. The code is provided with the stack for you to view and analyse.
    But basically when you add a function to the scheduler it records the time (in ms) that the function was added and will attempt to call it once the period has elapsed. They are all called in sequence, ie function_1 then function_2 etc. If there is a delay in function_1 so that it takes 20ms to complete then most likely function_2 and function_3 will be called straight after function_1. If the function finishes sooner it will loop waiting for the next one of the timeouts to have expired.

    There is also a mimimum scheduler period that you can define that will not call any of the functions unless the minimum period has expired.

  • Adhitya,

    Regarding how the scheduler works, I can give a little insight.

    The period for each task just means that the task will execute with that time period. For example, if task 1 has a period of 10, takes 1 ms to execute, and executes at t= 0, it will execute again at t = 10. In between those times, when task 1 is done running, the scheduler will insert other tasks to run (i.e. tasks do not run simultaneously).

    If task 2 has period of 10 and takes 1 ms to execute, it won't be able to begin until task 1 is complete; thus, it will execute at t = 1, and execute again at t = 11.

    In general, you should not assign a task a period shorter than its execution time, as that will cause the scheduler to get backed up and not be able to meet deadlines.

    It's hard to illustrate exactly how your proposed solution would work without knowing execution times of each, but essentially each task would execute one after the other, with the scheduler putting the functions in slots to meet the deadlines to the best of its ability.
  • Thanks for your help !
  • Thank you. I will be working closely with this. So, if I have any doubts, I will post again. For now, this has helped. Thanks.