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.

How to add a task on the cc2640 platform

Other Parts Discussed in Thread: CC2640, CC2650

Hi,

I want to add one or more tasks on SimpleBLEPeripheral basic(IAR,CC2640).But when I add one,the original task named SimpleBLEPeripheral is not normal when runing.And my mobile phone can't get the bluetooth signal named SimpleBLEPeripheral which is broadcast by the device.

My questions are as follows:

1.If I add a task,what I can do

2,How to  initialize the task during creating(include GATT,GAP, ICALL ,ect..)

3.Without disrupting the others,how to configure the Configuration parameters

Any idea how can I solve the problem? Every help would be really appreciated!

Thanks in advance.

Json

  • Moving this to "Bluetooth Low Energy Forum"

    Regards,
    Gigi Joseph.
  • Hi Json,

    can you provide a sample code snippet showing how you are adding a task? Without this it is hard to say what is wrong.

    Regards,
    Svend
  • Hi Svend,

    Fristly,Say thank you.

    Here is my code:

     void mcudbg_createTask(void)
    {
      Task_Params taskParams;
       
      // Configure task
      Task_Params_init(&taskParams);
      taskParams.stack = dbgTaskStack;
      taskParams.stackSize = DBG_TASK_STACK_SIZE;
      taskParams.priority = DBG_TASK_PRIORITY;
     
      Task_construct(&dbgTask, mcudbg_taskFxn, &taskParams, NULL);
    }

    static void dbgtask_init(void)
    {
     // Register the current thread as an ICall dispatcher application
     // so that the application can send and receive messages.
     ICall_registerApp(&dbgselfEntity, &dbgsem);

     // Hard code the BD Address till CC2650 board gets its own IEEE address
     // uint8 bdAddress[B_ADDR_LEN] = { 0xF0, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA };
     // HCI_EXT_SetBDADDRCmd(bdAddress);

     // Set device's Sleep Clock Accuracy
     //HCI_EXT_SetSCACmd(40);

     // Create an RTOS queue for message from profile to be sent to app.
     dbgMsgQueue = Util_constructQueue(&dbgMsg);

     // Create one-shot clocks for internal periodic events.
     Util_constructClock(&dbgperiodicClock, debug_clockHandler,
                     DBG_PERIODIC_EVT_PERIOD, 0, false, DBG_PERIODIC_EVT);

       /* Enroll the service that this stack represents */
       //ICall_enrollService( ICALL_SERVICE_CLASS_NPI, NULL, &dbgselfEntity, &dbgsem);
    }

     

    static void mcudbg_taskFxn(UArg a0, UArg a1)
    {
     uint8 *dbgstr = NULL;
     MCUDBGDef dbginfo;
     uint32 length = 32;
     int  ierr = 0;
     uint8  ucerr = 0;
     
     dbgtask_init();
     
     for(;;)
     {
      // Waits for a signal to the semaphore associated with the calling thread.
      // Note that the semaphore associated with a thread is signaled when a
      // message is queued to the message receive queue of the thread or when
      // ICall_signal() function is called onto the semaphore.
      ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);
      
      if (errno == ICALL_ERRNO_SUCCESS)
      {
        ICall_EntityID dest;
        ICall_ServiceEnum src;
        ICall_HciExtEvt *pMsg = NULL;
      
        if (ICall_fetchServiceMsg(&src, &dest,
             (void **)&pMsg) == ICALL_ERRNO_SUCCESS)
        {
       if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == dbgselfEntity))
       {
         // Process inter-task message
         //SimpleBLEPeripheral_processStackMsg((ICall_Hdr *)pMsg);
       }
      
       if (pMsg)
       {
         ICall_freeMsg(pMsg);
       }
        }
      
        // If RTOS queue is not empty, process app message.
        if (!Queue_empty(dbgMsgQueue))
        {
       dbgEvt_t *pMsg = (dbgEvt_t *)Util_dequeueMsg(dbgMsgQueue);
       if (pMsg)
       {
         // Process message.
         //SimpleBLEPeripheral_processAppMsg(pMsg);
      
         // Free the space from the message.
         ICall_free(pMsg);
       }
        }
      }
      
      if (events & DBG_PERIODIC_EVT)
      {
        events &= ~DBG_PERIODIC_EVT;

        Util_startClock(&dbgperiodicClock);

        // Perform periodic application task
        //SimpleBLEPeripheral_performPeriodicTask();
      }  
      Log_info0("qqqqqqqqqqqqqHello world\n");
     }
    }

     

    If adding all of functions to  SimpleBLEPeripheral's task,it will become bloated and huge.

    Due to this reason,I want add or creat some new tasks for my functions,and maybe the new tasks can use the data from the BLE task.

    I'm trying to make them have no influence on each other,But no effect

  • Hi,

    There is no need to have -any- API's towards the stack in your custom task, this can simply be a normal TI RTOS task that can pend on a semaphore and/or receive messages from the SimpleBLEPeripheral task.

    I suggest going through the SYS/BIOS user guide to get a better understanding of the TI RTOS mechanisms needed to achieve this (Tasks, Semaphores/Events, Queue)

    Regards,
    Svend
  • You can refer to section 3.5.1 Creating Tasks in SYS/BIOS (TI-RTOS kernel) user's guide at www.ti.com.cn/.../spruex3o.pdf.
  • Hi Svend,Yes,you are right. And,My idea is also like this.
    But,when I was testing, there were some issues happened.(IAs I mentioned in the beginning.)
    I have all these parameters(Tasks, Semaphores/Events, Queue)configured,but no use.
    So,If you can provide a successful example,I will be very grateful.Regards,Json